• 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

Excluding Category from Grid 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 › Design Tips and Tricks › Excluding Category from Grid Loop

This topic is: resolved

Tagged: alternative loop

  • This topic has 12 replies, 4 voices, and was last updated 13 years, 3 months ago by Terence.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • March 20, 2013 at 10:34 am #29718
    angieatc
    Member

    I have the grid loop on a site and I am wanting to exclude one category from it but I am not sure of the conditional tag to use. Here is what my home.php file looks like and the bolded area is what I added to excluded but it is not working so obviously, I am missing something and yes I have the correct ID for the category. Thanks!

    **edit: I removed the PHP opening tag

    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'child_grid_loop_helper' );
    /** Add support for Genesis Grid Loop **/
    function child_grid_loop_helper() {
    
    	if ( function_exists( 'genesis_grid_loop' ) ) {
    		genesis_grid_loop( array(
    			'features' => 1,
    			'feature_image_size' => 'Large Featured',
    			'feature_image_class' => 0,
    			'feature_content_limit' => 300,
    			'grid_image_size' => 'Small Featured',
    			'grid_image_class' => 0,
    			'grid_content_limit' => 250,
    			'more' => __( '[Read More]', 'genesis' ),
    			'posts_per_page' => 5,	
    			<b>'category__not_in' =&gt; array( 6 ),</b>
    
    
    
    
    		) );
    	} else {
    		genesis_standard_loop();
    	}
    
    }
    
    genesis();
    

    My design site, Hill Springs Designs

    March 20, 2013 at 10:39 am #29721
    Brad Dalton
    Participant

    What theme are you using? Why not use a custom function rather than edit template files?


    Tutorials for StudioPress Themes.

    March 20, 2013 at 10:41 am #29722
    angieatc
    Member

    I am using Mocha. Sorry I meant to put it in the original post.

    You can see it here: http://angiesweigh.com/


    My design site, Hill Springs Designs

    March 20, 2013 at 10:43 am #29723
    angieatc
    Member

    Oh and I am all about a custom function if I knew what I was writing! PHP and me do not get along all that well! Learning it but it is SLOW!


    My design site, Hill Springs Designs

    March 20, 2013 at 11:23 am #29730
    angieatc
    Member

    I added this plugin that you suggested from your site. It worked perfectly but I much prefer not to have to use a plugin and be able to add code to the functions or home file.

    Thanks


    My design site, Hill Springs Designs

    March 20, 2013 at 12:13 pm #29743
    Brad Dalton
    Participant

    This url should embed the code here otherwise grab the raw version from this link:

     


    Tutorials for StudioPress Themes.

    March 20, 2013 at 1:34 pm #29777
    Brad Dalton
    Participant

    I used this code https://gist.github.com/braddalton/5198288

    Change the category i.d


    Tutorials for StudioPress Themes.

    March 20, 2013 at 3:32 pm #29802
    angieatc
    Member

    Thank you for your help. I also found this solution as well. I found it somewhere on the old forums (I miss those).

    /** Don't Show Posts in Category 6 on the Home Page */

    function child_before_loop () {
    global $query_string;

    if( is_home() )
    query_posts($query_string . "&cat=-6");
    }

    I am definitely going to evernote your codes those because it is just something else to learn!


    My design site, Hill Springs Designs

    March 20, 2013 at 3:59 pm #29805
    Brad Dalton
    Participant

    Andrew Nacin made a video about it pre_get_posts recently http://wordpress.tv/2013/03/15/andrew-nacin-wp_query-wordpress-in-depth/


    Tutorials for StudioPress Themes.

    March 20, 2013 at 5:16 pm #29821
    angieatc
    Member

    Thanks Brad! I am going to definitely watch it. I need all the help I can get. I am slowly learning it but I wish it would just come to me but it is not.

    I have learned so much from your site as well! I really do appreciate all the help!


    My design site, Hill Springs Designs

    March 26, 2013 at 12:48 pm #31377
    Noe Garcia
    Member

    Hello - I'm battling with the same thing.

    I'm trying to remove cat  from the main page, I have try the code you show above but its not working, I use Minimum theme.

    This is what I'm now trying and still nothing - any help? I thought by adding the -cat not in- will get it off but was wrong.

    add_action( 'genesis_loop', 'minimum_grid_loop_helper' );
    function minimum_grid_loop_helper() {
    
    if ( function_exists( 'genesis_grid_loop' ) ) {
    genesis_grid_loop( array(
    'features' =&gt; 5,
    'feature_image_size' =&gt; '0',
    'feature_image_class' =&gt; 'post-image',
    'feature_content_limit' =&gt; 0,
    <strong>'category__not_in' =&gt; '5',</strong>
    'grid_image_size' =&gt; 0,
    'grid_image_class' =&gt; 'alignnone',
    'grid_content_limit' =&gt; 1500,
    'more' =&gt; __( '[Read more]', 'minimum' ),
    ) );
    } else {
    genesis_standard_loop();
    }
    
    }
    
    March 26, 2013 at 7:28 pm #31439
    Brad Dalton
    Participant

    The code i posted above works but you need to add your own category i.d. for the cat you want to exclude.

    There's a plugin which you might find useful http://www.studiopress.community/topic/excluding-category-from-grid-loop/#post-29730


    Tutorials for StudioPress Themes.

    April 1, 2013 at 6:58 pm #32543
    Terence
    Member

    Brad,

    How come you can dig in and really help these guys with code and ideas, and all you can do for me [ http://www.studiopress.community/topic/cornerstone-sections-and-not-faking-site-structure/#post-31717 ] is send me to other people's websites?

    I don't mean that all bitter and twisted ~ its a serious question.

    I have been struggling with this for days and without an answer I have wasted my money on both Dynamik/Genesis, so you can see why any help I can get would be very much appreciated.

    Terence.

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

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