Last active
April 26, 2020 09:12
-
-
Save VelichkoAlexander/2157aeb133247f98a9ce4ca8e75f315f to your computer and use it in GitHub Desktop.
Create custom post type
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
add_action( 'init', 'true_register_post_type_init' ); | |
function true_register_post_type_init() { | |
$labels = [ | |
'name' => 'Functions', | |
'singular_name' => 'Function', // admin panel Add-> Function | |
'add_new' => 'Add function', | |
'add_new_item' => 'Add New function', // <title> tag title | |
'edit_item' => 'Edit function', | |
'new_item' => 'New feature', | |
'all_items' => 'All functions', | |
'view_item' => 'View function on site', | |
'search_items' => 'Search functions', | |
'not_found' => 'No functions found.', | |
'not_found_in_trash' => 'There are no functions in the basket.', | |
'menu_name' => 'WP Code' // link in the admin menu | |
]; | |
$args = [ | |
'labels' => $labels, | |
'public' => true, | |
'show_ui' => true, // show interface in admin panel | |
'has_archive' => true, | |
'menu_icon' => get_stylesheet_directory_uri() .'/img/function_icon.png', // menu icon | |
'menu_position' => 20, // order in the menu | |
'supports' => array( 'title', 'editor', 'comments', 'author', 'thumbnail') | |
]; | |
register_post_type('functions', $args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment