admin管理员组文章数量:1389754
I am adding Custom Post Types to my wordpress dashboard. When a new CPT is added it is added to the bottom of the menu. I would prefer for the CPT menu items to be in alphabetical order.
For example, in the image below I added a new CPT called 'Animations / Films / Aerials' and it is inserted at the bottom of the menu order:
What solutions have I looked for before posting? I have looked for answers on stack but I haven't found a clear solution. I also read through the documentation here: . It seems like the menu-position
property doesn't allow you to change the order of CPT's relative to one another. What needs to be done if I want these CPT's to be in alphabetical order in the admin menu?
I am adding Custom Post Types to my wordpress dashboard. When a new CPT is added it is added to the bottom of the menu. I would prefer for the CPT menu items to be in alphabetical order.
For example, in the image below I added a new CPT called 'Animations / Films / Aerials' and it is inserted at the bottom of the menu order:
What solutions have I looked for before posting? I have looked for answers on stack but I haven't found a clear solution. I also read through the documentation here: https://codex.wordpress/Function_Reference/register_post_type#Parameters. It seems like the menu-position
property doesn't allow you to change the order of CPT's relative to one another. What needs to be done if I want these CPT's to be in alphabetical order in the admin menu?
1 Answer
Reset to default 1Here is an example of one way I have managed to edits those:
function wpse_custom_menu_order( $menu_ord ) {
if ( !$menu_ord ) return true;
return array(
'index.php', // Dashboard
'separator1', // First separator
'edit.php', // Posts
'upload.php', // Media
'link-manager.php', // Links
'edit-comments.php', // Comments
'edit.php?post_type=page', // Pages
'separator2', // Second separator
'themes.php', // Appearance
'plugins.php', // Plugins
'users.php', // Users
'tools.php', // Tools
'options-general.php', // Settings
'separator-last', // Last separator
);
}
add_filter( 'custom_menu_order', 'wpse_custom_menu_order', 10, 1 );
add_filter( 'menu_order', 'wpse_custom_menu_order', 10, 1 );
More info:
https://developer.wordpress/reference/hooks/custom_menu_order/ https://developer.wordpress/reference/hooks/menu_order/
I have found using this plugin to be the smoothest also you can poke around the code to see how they do it: https://wordpress/plugins/admin-menu-editor/. Its a free plugin!
本文标签: Custom Post TypesChange order of menu items
版权声明:本文标题:Custom Post Types - Change order of menu items 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744628555a2616403.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论