Last active
January 17, 2019 17:07
-
-
Save junaidtk/84efe1f58ade02a5a60bc84663e3a176 to your computer and use it in GitHub Desktop.
WP Post type creation from function.php
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
For creating a new post types in wordpress admin panel we can use below function in init hook. | |
function theme_posttype() { | |
register_post_type('portfolio', array('label' => 'Works', | |
'description' => '', | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'capability_type' => 'page', | |
'hierarchical' => false, | |
'query_var' => true, | |
'has_archive' => true, | |
'exclude_from_search' => false, | |
'supports' => array('title', 'editor', 'thumbnail'), | |
'taxonomies' => array('post_tag'), | |
//'menu_icon' => 'dashicons-video-alt3', | |
'labels' => array( | |
'name' => 'Portfolio', | |
'singular_name' => 'Portfolio', | |
'menu_name' => 'Portfolio', | |
'add_new' => 'Add New Portfolio', | |
'add_new_item' => 'Add New Portfolio', | |
'edit' => 'Edit Portfolio', | |
'edit_item' => 'Edit Portfolio', | |
'new_item' => 'New Portfolio', | |
'view' => 'View Portfolio', | |
'view_item' => 'View Portfolio', | |
'search_items' => 'Search Portfolio', | |
'not_found' => 'No Portfolio Found', | |
'not_found_in_trash' => 'No Portfolio Found in Trash', | |
'parent' => 'Parent Portfolio', | |
))); | |
register_taxonomy( | |
'work-category', 'portfolio', array( | |
'label' => __('Portfolio Categories'), | |
'hierarchical' => true, | |
'show_admin_column' => true | |
) | |
); | |
} | |
add_action('init', 'theme_posttype'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment