Support » Fixing WordPress » How to add custom post type archive slug to nav menu?

  • Resolved Harryson


    I cannot figure this out. There seems to be no checkbox or anything similar in function to add the newly created custom post type archive page into the menu.

    Also the link must be active, if you are on the page. This probably isn’t possible, but is there some plugin for it? For the love of me, I cannot find it 🙁

    It is surprising that such important function isn’t highlighted or easy to find. As most of stuff will be custom post type. In my case 90% of my site will use custom post types, and if I’m missing 90% of my links or they won’t work like they should.. then that’s a very huge problem.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Harryson


    Ok found the plugin Custom Post Type Archives in Nav Menus, however it just adds a custom link and doesn’t really help anything..

    Thread Starter Harryson


    Up, still cant figure this out.

    Thread Starter Harryson


    Maybe it is possible by overriding everything and adding the menu links to the nav manually? And also detecting the active link with $_GET.

    Thread Starter Harryson


    Based on the answer I got from:

    I forked that function to be more dynamic:

    add_filter('wp_list_pages', 'new_nav_menu_items');
    add_filter('wp_nav_menu_items', 'new_nav_menu_items');
    function new_nav_menu_items($items) {
    	global $wp_query;
    	$class = 'menu-item menu-item-type-post_type menu-item-object-page';
    	foreach ($GLOBALS['posttypelinks'] as $link) {
    		$items .= '<li class="' . $classes . ' ' . (isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == $link['post_type'] ? 'current_page_item' : '') . '"><a href="' . site_url() . '/' . $link['slug'] . '">' . $link['title'] . '</a></li>';
    	return $items;

    So, I could add my post-types to menu like this (inside create_post_type()):

    $GLOBALS['posttypelinks'][] = array(
    	'title' => $title,
    	'post_type' => $post_type,
    	'slug' => $slug

    These variables are the same, that are being used inside register_post_type()‘s array. Probably could be better solution and maybe in the form of a plugin..however, it does the trick perfectly.


    If you want to add the whole Custom post into the menu ( archive ) there are 2 ways:

    1. The clean way
      Custom Post types have their own permalink – So in the menu navigation you create your Custom Menu Item with a link to

      After thats done you can customize the taxonomy with a template that sould be named as follows:
      and then you code it as you wish.

    2. the developer friendly way
      create a custom Page template and force the loop of custom posts like so:

      $loop = new WP_Query( array( 'post_type' => 'POST TYPE', 'posts_per_page' => 10 ) );
      while ( $loop->have_posts() ) : $loop->the_post();
      your loop stuff
      <?php endwhile; ?>

    If you want to add a specific custom post ( or a category ) then ytou should be able to do that in WP nav menu section. MAybe check the screen options.

    If its not there, then your code fr the custom posts is not set to display it in the menu.

    oh…. forgot to add that in point 2 – after creating a custom page template:
    create a regular page and save it with the new page template that you have just created.
    then ofc add that to the menu.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to add custom post type archive slug to nav menu?’ is closed to new replies.