Support » Themes and Templates » Twenty Eleven custom post types won't display on home

  • Hi, I have a custom post type “review” and cannot get the posts to display on the main page. I want the other post types (aside, gallery, etc.) to display as well.

    There is no “loop.php” file – where do I add the code to get the custom post type to display?

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi


    Forum Moderator

    Do not edit the Twenty Eleven theme. It is the default WordPress 3.2 theme and having access to an unedited version of the theme is vital when dealing with a range of site issues.

    Create a child theme for your customisations. Once your child theme is active, we should be able to help with the customisation.

    Thanks esmi for your reply! I do have a child theme set up. I have added the following line & it works. Is this OK? Just to make sure.

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    	if ( is_home() && false == $query->query_vars['suppress_filters'] )
    		$query->set( 'post_type', array( 'post', 'review' ) );
    	return $query;


    Forum Moderator

    It seems OK but not sure why you’re checking for suppress_filters.

    After much head-scratching, I have used the following code to display my custom post-type ‘review’ on my index/home page AND on my category archive pages. The problem is the ‘menu_nav_item’ addition causes additional “posts’ to show on my index/home page that were created when I created my menu! I am very confused. Please help! I have incuded my code in my child functions file:

    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if(is_category() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) )  {
        $post_type = get_query_var('post_type');
    	    $post_type = $post_type;
    	    $post_type = array('post','review','nav_menu_item');
    	return $query;

    <article id=”post-249″ class=”post-249 nav_menu_item type-nav_menu_item status-publish hentry”>

    The above is the the post that is showing up since it is of type nav_menu_item (there are additional ones as well, since I have multiple nav menu items. If I remove the ‘nav_menu_item’ from the array, my nav menu does not display on category or tag archive pages.

    Should I just exlude this post-type from the loop? If so, how do I do that? Thanks in advance!!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Twenty Eleven custom post types won't display on home’ is closed to new replies.