These are the args I used to get "Artists" display above "Master Artist Lookup" using the "menu_position" parameter. However , still does not display in menu correctly
$args = [
'label' => __('Artists', SMF_CORE_NAME),
'labels' => [
'name' => __('Artists', SMF_CORE_NAME),
'singular_name' => __('Artist'),
'add_new_item' => __('Add New Artist', SMF_CORE_NAME),
'add_new' => __('Add New Artist', SMF_CORE_NAME),
'new_item' => __('Add New Artist', SMF_CORE_NAME),
'all_items' => __('All Artists', SMF_CORE_NAME),
'edit_item' => __('Edit Artist', SMF_CORE_NAME)
],
'supports' => ['title', 'thumbnail'],
'hierarchical' => false,
'public' => true,
'menu_icon' => 'dashicons-format-audio',
'can_export' => true,
'has_archive' => false,
'publicly_queryable' => false,
'menu_position' => '20.1',
];
$args = [
'label' => __('Master Artist Lookup', SMF_CORE_NAME),
'labels' => [
'name' => __('Master Artist Lookup', SMF_CORE_NAME),
'singular_name' => __('Master Artist Lookup'),
'add_new_item' => __('Add New Artist', SMF_CORE_NAME),
'add_new' => __('Add New Artist', SMF_CORE_NAME),
'new_item' => __('Add New Artist', SMF_CORE_NAME),
'all_items' => __('All Artists', SMF_CORE_NAME),
'edit_item' => __('Edit Artist', SMF_CORE_NAME)
],
'supports' => ['title', 'thumbnail'],
'hierarchical' => false,
'public' => true,
'menu_icon' => 'dashicons-format-audio',
'can_export' => true,
'has_archive' => false,
'publicly_queryable' => false,
'menu_position' => '20.2',
];
These are the args I used to get "Artists" display above "Master Artist Lookup" using the "menu_position" parameter. However , still does not display in menu correctly
$args = [
'label' => __('Artists', SMF_CORE_NAME),
'labels' => [
'name' => __('Artists', SMF_CORE_NAME),
'singular_name' => __('Artist'),
'add_new_item' => __('Add New Artist', SMF_CORE_NAME),
'add_new' => __('Add New Artist', SMF_CORE_NAME),
'new_item' => __('Add New Artist', SMF_CORE_NAME),
'all_items' => __('All Artists', SMF_CORE_NAME),
'edit_item' => __('Edit Artist', SMF_CORE_NAME)
],
'supports' => ['title', 'thumbnail'],
'hierarchical' => false,
'public' => true,
'menu_icon' => 'dashicons-format-audio',
'can_export' => true,
'has_archive' => false,
'publicly_queryable' => false,
'menu_position' => '20.1',
];
$args = [
'label' => __('Master Artist Lookup', SMF_CORE_NAME),
'labels' => [
'name' => __('Master Artist Lookup', SMF_CORE_NAME),
'singular_name' => __('Master Artist Lookup'),
'add_new_item' => __('Add New Artist', SMF_CORE_NAME),
'add_new' => __('Add New Artist', SMF_CORE_NAME),
'new_item' => __('Add New Artist', SMF_CORE_NAME),
'all_items' => __('All Artists', SMF_CORE_NAME),
'edit_item' => __('Edit Artist', SMF_CORE_NAME)
],
'supports' => ['title', 'thumbnail'],
'hierarchical' => false,
'public' => true,
'menu_icon' => 'dashicons-format-audio',
'can_export' => true,
'has_archive' => false,
'publicly_queryable' => false,
'menu_position' => '20.2',
];
Share
Improve this question
asked May 20, 2020 at 16:38
daily-learnerdaily-learner
1133 bronze badges
1
- This has frustrated me for ages and all the documentation I've read in the codex and on other similar questions produces mixed results. It's super frustrating. I've used the decimal method but in quite a few instances have just left things as 'this is the best I'm going to get'. Would love to see some answers to this one. – Tony Djukic Commented May 20, 2020 at 17:24
1 Answer
Reset to default 1There are two ways to affect where CPTs appear in the admin menu: using menu_position
and controlling when the CPTs are registered.
Using decimal numbers hasn't been reliable in my experience; using an integer like 21
, 22
, etc. has been more effective. If you have so many CPTs there aren't enough integers, the other trick is to register the one you want first first, then register the second, then register the third. By controlling the code order, and keeping the menu_position
the same for all of them, WP will put them in the order you register them in.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742415699a4439699.html
评论列表(0条)