• 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

Exclude posts from blog page but not from category page

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 › Exclude posts from blog page but not from category page

This topic is: not resolved

Tagged: blogs, multiple blogs

  • This topic has 3 replies, 2 voices, and was last updated 2 years, 1 month ago by SharonLandis.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • January 30, 2021 at 11:22 am #502844
    SharonLandis
    Participant

    I'm using the Genesis child theme.

    There are 2 feed pages on my site: Blog and Podcast (cat-id 7).

    The podcast posts (cat 7) show up in both feeds.
    To exclude podcast posts only from the blog I tried the PHP below, but it excludes from both feeds. How do I exclude cat 7 from the blog and keep it on the podcast page?

    // Exclude categories from blog.
    add_action( 'pre_get_posts', 'exclude_categories_blog' );
    function exclude_categories_blog_archive( $query ) {
    if( $query->is_main_query() ) {
    $query->set( 'cat', '-7' );
    }
    }

    http://slandisconsulting.com
    January 30, 2021 at 12:12 pm #502846
    Anita
    Keymaster

    You can do that right on the blog page without adding that function. See Custom Blog Page here.


    Love coffee, chocolate and my Bella!

    January 30, 2021 at 1:26 pm #502852
    SharonLandis
    Participant
    This reply has been marked as private.
    January 30, 2021 at 2:24 pm #502853
    SharonLandis
    Participant

    Got it working.
    1. I used the above PHP to exclude cat 7 from the blog. For some reason it doesn't recognize custom fields.
    2. Created a custom blog page as per your suggested post. Custom fields for this page do work.

    Thanks

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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

© 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