WordPress.org

Ready to get started?Download WordPress

Forums

nav_menu_items showing in Recent Posts (2 posts)

  1. 50020
    Member
    Posted 2 years ago #

    Hi,

    I have added custom post types to my theme. So that these cpt's shouw up when browsing by 'category' and 'tag' I have added the following code to my functions.php

    function query_post_type($query) {
      if(is_category() || is_tag() ) {
        $post_type = get_query_var('post_type');
    	$post_type = array('post', 'photo', 'photo365', 'nav_menu_item');
    	wp_reset_query();
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('post', 'photo', 'photo365'); // replace cpt to your custom post type
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    but the widget that shows the recent posts, shows the recent 8 posts which I ask for, but this also inludes the 'nav_menu_item' which is a type of post.

    Now, I need 'nav_menu_item' in the code above so that the nav menu is displayed in the header, without I get a blank nav menu.

    How do I stop the nav_menu_items showing in the recent posts? I can't believe that I am the only one with this issue, and it's driving me nuts!

    regards

    S

  2. 50020
    Member
    Posted 2 years ago #

    for a demo, I have switched the 'maintenance mode' off...

    http://www.silversnaps.co.uk/

    and

    http://www.silversnaps.co.uk/category/street-photography/

    regards

Topic Closed

This topic has been closed to new replies.

About this Topic