• 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

Stream Page Posts not in TAGS' Results

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 › Design Tips and Tricks › Stream Page Posts not in TAGS' Results

This topic is: not resolved
  • This topic has 3 replies, 2 voices, and was last updated 9 years, 4 months ago by francky.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 12, 2013 at 8:04 am #55777
    francky
    Member

    I have the code below to add a Stream Page in my website but the problem I have is that when accessing a certain TAG Page eg. http://www.example.com/tag/election , a post with tag "election" in the stream doesn't show up! But if there is any normal blog post with the same tag, it shows up! The problem is only with the "Stream Posts".
    How can I have this work? Thank you in advance!

    //* Create stream custom post type
    add_action( 'init', 'stream_post_type' );
    function stream_post_type() {
        register_post_type( 'stream',
            array(
                'labels' => array(
                    'name' => __( 'The Stream' ),
                    'singular_name' => __( 'Stream' ),
                ),
                'has_archive' => true,
                'hierarchical' => true,
                'taxonomies' => array( 'post_tag' ),
                'public' => true,
                'rewrite' => array( 'slug' => 'stream' ),
                'supports' => array( 'title', 'editor', 'custom-fields', 'genesis-seo', 'thumbnail', 'comments' ),
            )
        );
    }
    http://tags, stream page, stream
    September 3, 2013 at 12:37 am #60367
    francky
    Member

    Anyone who can help me with this please?

    September 3, 2013 at 9:14 am #60430
    Norcross
    Member

    by default, the tag archive page won't include any post type other than posts. you need to include your post type in there with a pre_get_posts filter. This code should do it.

    function stream_to_tag_loop( $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', 'stream' );
    
    		return;
    	}		
    		
    }
    
    add_action ( 'pre_get_posts', 'stream_to_tag_loop' );
    September 3, 2013 at 10:32 am #60454
    francky
    Member

    WoW!! PERFECT!
    It worked like a charm! WoW!

    Thank you very much @Norcross

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ 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

© 2023 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