Примеры работ

Регистрация  Post Type

https://codex.wordpress.org/Post_Types

functions.php

 


//Запись по умолчанию из документации
function create_post_type() {
  register_post_type( 'acme_product',//имя посттайпа
    array(
      'labels' => array(
        'name' => __( 'Products' ), //имя посттайпа отображаемое на сайте
        'singular_name' => __( 'Product' )// тож самое в един числ
      ),
      'public' => true,
      'has_archive' => true,
    )
  );
}
add_action( 'init', 'create_post_type' );



Дополнительные пользовательские настройки.

https://codex.wordpress.org/Function_Reference/register_post_type

Arguments

label
(string) (optional) A plural descriptive name for the post type marked for translation.
Default: Value of $labels['name']
labels
(array) (optional) labels - An array of labels for this post type. By default, post labels are used for non-hierarchical post types and page labels for hierarchical ones.
Default: if empty, 'name' is set to value of 'label', and 'singular_name' is set to value of 'name'.
  • 'name' - general name for the post type, usually plural. The same and overridden by $post_type_object->label. Default is Posts/Pages
  • 'singular_name' - name for one object of this post type. Default is Post/Page
  • 'add_new' - the add new text. The default is "Add New" for both hierarchical and non-hierarchical post types. When internationalizing this string, please use a gettext context matching your post type. Example: _x('Add New', 'product');
  • 'add_new_item' - Default is Add New Post/Add New Page.
  • 'edit_item' - Default is Edit Post/Edit Page.
  • 'new_item' - Default is New Post/New Page.
  • 'view_item' - Default is View Post/View Page.
  • 'view_items' - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
  • 'search_items' - Default is Search Posts/Search Pages.
  • 'not_found' - Default is No posts found/No pages found.
  • 'not_found_in_trash' - Default is No posts found in Trash/No pages found in Trash.
  • 'parent_item_colon' - This string isn't used on non-hierarchical types. In hierarchical ones the default is 'Parent Page:'.
  • 'all_items' - String for the submenu. Default is All Posts/All Pages.
  • 'archives' - String for use with archives in nav menus. Default is Post Archives/Page Archives.
  • 'attributes' - Label for the attributes meta box. Default is 'Post Attributes' / 'Page Attributes'.
  • 'insert_into_item' - String for the media frame button. Default is Insert into post/Insert into page.
  • 'uploaded_to_this_item' - String for the media frame filter. Default is Uploaded to this post/Uploaded to this page.
  • 'featured_image' - Default is Featured Image.
  • 'set_featured_image' - Default is Set featured image.
  • 'remove_featured_image' - Default is Remove featured image.
  • 'use_featured_image' - Default is Use as featured image.
  • 'menu_name' - Default is the same as `name`.
  • 'filter_items_list' - String for the table views hidden heading.
  • 'items_list_navigation' - String for the table pagination hidden heading.
  • 'items_list' - String for the table hidden heading.
  • 'name_admin_bar' - String for use in New in Admin menu bar. Default is the same as `singular_name`.

 



function
watch_init() { register_post_type( 'xlo_watch', array( 'labels' => array( 'name' => __( 'Watches' ), 'singular_name' => __( 'Whatch' ), 'add_new' => __('Добавить новый') ), 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'post-formats'), 'menu_icon' => 'dashicons-smiley', 'rewrite' => 'watch', 'public' => true, 'has_archive' => true, ) ); } add_action( 'init', 'watch_init' );

Возможная ошибка 404:

https://youtu.be/O9j-R-GwCt4?t=871