Excluding Category from Grid Loop

Community Forums Forums Design Tips and Tricks Excluding Category from Grid Loop

This topic is: resolved

This topic contains 12 replies, has 4 voices, and was last updated by  Terence 1 year, 8 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #29718

    angieatc
    Participant
    Post count: 80

    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
    [php]
    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();
    [/php]

    #29721

    braddalton
    Participant
    Post count: 10671

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


    #29722

    angieatc
    Participant
    Post count: 80

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

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

    #29723

    angieatc
    Participant
    Post count: 80

    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!

    #29730

    angieatc
    Participant
    Post count: 80

    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

    #29743

    braddalton
    Participant
    Post count: 10671

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

     


    #29777

    braddalton
    Participant
    Post count: 10671
    #29802

    angieatc
    Participant
    Post count: 80

    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!

    #29805

    braddalton
    Participant
    Post count: 10671
    #29821

    angieatc
    Participant
    Post count: 80

    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!

    #31377

    nglstudios
    Participant
    Post count: 14

    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.

    [php]
    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();
    }

    }
    [/php]

    #31439

    braddalton
    Participant
    Post count: 10671

    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.com/forums/topic/excluding-category-from-grid-loop/#post-29730


    #32543

    Terence
    Participant
    Post count: 42

    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.com/forums/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.

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.