If you want to add custom post type to nav_menu in WordPress? 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.
Add the below code in your theme’s functions.php file OR in site specific plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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' ) ) ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.