I have a question.
I use the new custom menus
of Wordpress 3.0. And I'm wondering how can I add custom post types to the menu. For now, I can just add Pages
and Categories
.
Thanks
Advanced Custom FieldsSelect 'Menu Item' under the location rules. Follow the instructions and update the fields as required. Once you publish the field you can head to your WordPress menu from within the Admin area to see the new field you've created. Pretty easy!
To add a custom navigation menu, the first thing you need to do is register your new navigation menu by adding this code to your theme's functions. php file. add_action( 'init' , 'wpb_custom_new_menu' ); You can now go to Appearance » Menus page in your WordPress admin and try to create or edit a new menu.
The function register_post_type() takes an argument show_in_nav_menus
. If you set this to TRUE
you get a selector for your custom post type in the menu manager.
register_post_type(
'post_type_name'
, array (
'can_export' => TRUE
, 'exclude_from_search' => FALSE
, 'has_archive' => TRUE
, 'hierarchical' => TRUE
, 'label' => 'CPT Test'
, 'menu_position' => 5
, 'public' => TRUE
, 'publicly_queryable' => TRUE
, 'query_var' => 'cpttest'
, 'rewrite' => array ( 'slug' => 'cpt-test' )
, 'show_ui' => TRUE
, 'show_in_menu' => TRUE
, 'show_in_nav_menus' => TRUE
, 'supports' => array ( 'editor', 'title' )
)
);
Screen shot with the custom post type named CPT Test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With