Created
October 20, 2016 08:22
-
-
Save ibrahimkholil/cfc27f10aad5319d70ad219e7f30787d to your computer and use it in GitHub Desktop.
Register post type in wordlress
This file contains 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 | |
function corlate_theme_custom_post_type() { | |
$labels = array( | |
'name' => _x( 'Sliders', 'Post Type General Name', 'corlate' ), | |
'singular_name' => _x( 'Slider', 'Post Type Singular Name', 'corlate' ), | |
'menu_name' => __( 'Slider', 'corlate' ), | |
'name_admin_bar' => __( 'Slider', 'corlate' ), | |
'archives' => __( 'Item Archives', 'corlate' ), | |
'parent_item_colon' => __( 'Parent Item:', 'corlate' ), | |
'all_items' => __( 'All Items', 'corlate' ), | |
'add_new_item' => __( 'Add New Slider', 'corlate' ), | |
'add_new' => __( 'Add New Slider', 'corlate' ), | |
'new_item' => __( 'New Slider', 'corlate' ), | |
'edit_item' => __( 'Edit Slider', 'corlate' ), | |
'update_item' => __( 'Update Slider', 'corlate' ), | |
'view_item' => __( 'View Slider', 'corlate' ), | |
'search_items' => __( 'Search Slider', 'corlate' ), | |
'not_found' => __( 'Not found', 'corlate' ), | |
'not_found_in_trash' => __( 'Not found in Trash', 'corlate' ), | |
'featured_image' => __( 'Featured Image', 'corlate' ), | |
'set_featured_image' => __( 'Set featured image', 'corlate' ), | |
'remove_featured_image' => __( 'Remove featured image', 'corlate' ), | |
'use_featured_image' => __( 'Use as featured image', 'corlate' ), | |
'insert_into_item' => __( 'Insert into item', 'corlate' ), | |
'uploaded_to_this_item' => __( 'Uploaded to this item', 'corlate' ), | |
'items_list' => __( 'Sliders list', 'corlate' ), | |
'items_list_navigation' => __( 'Sliders list navigation', 'corlate' ), | |
'filter_items_list' => __( 'Filter Sliders list', 'corlate' ), | |
); | |
$args = array( | |
'label' => __( 'Slider', 'corlate' ), | |
'description' => __( 'Slider Description', 'corlate' ), | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', ), | |
'taxonomies' => array( 'category', 'slider_tag' ), | |
'hierarchical' => false, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'menu_position' => 5, | |
'show_in_admin_bar' => true, | |
'show_in_nav_menus' => true, | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'capability_type' => 'page', | |
); | |
register_post_type( 'slider', $args ); | |
} | |
add_action( 'init', 'corlate_theme_custom_post_type', 0 ); | |
Note: if u dont enable theme support= add_theme_support('post-thumbnails',array('slider')); | |
you cant see feature image option in your custom post |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment