• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Custom Post Types and Home Loop

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Custom Post Types and Home Loop

This topic is: not resolved

Tagged: Archive Loops, custom post types

  • This topic has 2 replies, 3 voices, and was last updated 10 years, 1 month ago by esquivelia.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 10, 2014 at 6:24 pm #84555
    Lord_Devi
    Participant

    Hi All,

    So thanks to some help I've recieved on the forums in the past here, I've been able to add my Custom Post Type to my Tags and Categories archive loops just fine. But the same code is not working for my home loop for some reason, and I am hoping someone might be able to help me out with it.

    I have a Custom Post Type called "Reviews". I added the default taxonomies of Categories and Tags to it as well. So I wanted it to appear in my Category and Tag archive loops. This is working fine. But from everything I've found in the WordPress Codex and otherwise, I should be able to do the exact same thing to get them to display on my home page (Latest Posts).

    This is the code I am currently using to achieve this. It's the "is_home()" part of the code that is not working correctly though:

    /* ----------------------------------------------- */
    /* Add custom post type "reviews" to archive loops */
    /* ----------------------------------------------- */
    function reviews_to_archive_loops( $query ) {
    	// we don't want this running on the admin side
    	if ( is_admin() )
    		return;
    	// include our stream type on tag pages
    	if ( is_tag() && $query->is_main_query() ) {
    		$query->query_vars['post_type'] = array( 'post', 'reviews' );
    		return;
    	}
        // include our stream type on category pages
        if ( is_category() && $query->is_main_query() ) {
    		$query->query_vars['post_type'] = array( 'post', 'reviews' );
    		return;
    	}
        // include our stream type on home page
    	if ( is_home() && $query->is_main_query() ) {
    		$query->query_vars['post_type'] = array( 'post', 'reviews' );
    		return;
    	}
    }
    add_action ( 'pre_get_posts', 'reviews_to_archive_loops' );
    January 10, 2014 at 10:54 pm #84582
    Summer
    Member

    Try using this:

    if ( is_front_page() && $query->is_main_query() )


    WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
    Slice of SciFi | Writers, After Dark

    March 31, 2015 at 1:55 pm #146297
    esquivelia
    Member

    Any luck figuring this out?

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble