• Hi Guys,

    I use the following snippet in my functions.php to add custom post types to my tag page.

    add_filter('pre_get_posts', 'custom_post_types_in_results');
    
    function custom_post_types_in_results($query) {
    
    	if(is_tag()) {
    
    		$post_type = get_query_var('post_type');
    
    		if($post_type)
    			$post_type = $post_type;
    		else
    			$post_type = array('nieuws', 'diensten', 'referenties', 'menu');
    
    		$query->set('post_type',$post_type);
    
    		return $query;
    	}
    
    }

    However, because of this snippet the menu’s are not being displayed. Which is logic because I edit every query on the page to these specific post types.

    I had in mind that I could solve this by adding the menu post type to it, but I cannot seem to find what the post type for menu items is.

    How can help me solve this problem? Or I need to be able to minimize the function to the actual search results and not all queries. OR I need to add the menu post type to this change. Who knows?

Viewing 1 replies (of 1 total)
  • Thread Starter HarroH

    (@harroh)

    Never mind, added ‘nav_menu_item’ to the $post_type variable and solved it all.

    You always see that you find the answer yourself as soon as you ask for help 😉

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Types in Tag Page make Manu disapear’ is closed to new replies.