Last active
March 14, 2019 01:37
-
-
Save joshapgar/2cf759f4494c8d0650751156a1ba821b to your computer and use it in GitHub Desktop.
Custom Post Type with all the options.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! function_exists('portfolio_post_type') ) : | |
// Add Portfolio Projects to WordPress | |
add_action( 'init', 'portfolio_post_type', 0 ); | |
// Register Portfolio Projects Custom Post Type | |
function portfolio_post_type() | |
{ | |
$labels = array( | |
'name' => _x( 'Portfolio', 'Post Type General Name' ), | |
'singular_name' => _x( 'Project', 'Post Type Singular Name' ), | |
'menu_name' => __( 'Portfolio Projects' ), | |
'name_admin_bar' => __( 'Portfolio Project' ), | |
'archives' => __( 'Portfolio Archives' ), | |
'parent_item_colon' => __( 'Parent Project:' ), | |
'all_items' => __( 'All Projects' ), | |
'add_new_item' => __( 'Add New Project' ), | |
'add_new' => __( 'Add New' ), | |
'new_item' => __( 'New Project' ), | |
'edit_item' => __( 'Edit Project' ), | |
'update_item' => __( 'Update Project' ), | |
'view_item' => __( 'View Project' ), | |
'search_items' => __( 'Search Projects' ), | |
'not_found' => __( 'Not found' ), | |
'not_found_in_trash' => __( 'Not found in Trash' ), | |
'featured_image' => __( 'Featured Image' ), | |
'set_featured_image' => __( 'Set featured image' ), | |
'remove_featured_image' => __( 'Remove featured image' ), | |
'use_featured_image' => __( 'Use as featured image' ), | |
'insert_into_item' => __( 'Insert into project' ), | |
'uploaded_to_this_item' => __( 'Uploaded to this project' ), | |
'items_list' => __( 'Projects list' ), | |
'items_list_navigation' => __( 'Projects list navigation' ), | |
'filter_items_list' => __( 'Filter projects list' ), | |
); | |
$rewrite = array( | |
'slug' => 'portfolio', | |
'with_front' => true, | |
'pages' => true, | |
'feeds' => true, | |
); | |
$args = array( | |
'label' => __( 'Project' ), | |
'description' => __( 'Portfolio projects for Apgar Digital LLC.' ), | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions', ), | |
'taxonomies' => array( ), | |
'hierarchical' => false, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'menu_position' => 5, | |
'menu_icon' => 'dashicons-portfolio', | |
'show_in_admin_bar' => true, | |
'show_in_nav_menus' => true, | |
'show_in_rest' => true, | |
'can_export' => true, | |
'has_archive' => 'portfolio', | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'rewrite' => $rewrite, | |
'capability_type' => 'page', | |
); | |
register_post_type( 'portfolio', $args ); | |
} | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment