Community Forums › Forums › Archived Forums › Design Tips and Tricks › Excluding Category from Grid Loop
Tagged: alternative loop
- This topic has 12 replies, 4 voices, and was last updated 11 years ago by Terence.
-
AuthorPosts
-
March 20, 2013 at 10:34 am #29718angieatcMember
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' => array( 6 ),</b> ) ); } else { genesis_standard_loop(); } } genesis();
My design site, Hill Springs Designs
March 20, 2013 at 10:39 am #29721Brad DaltonParticipantWhat theme are you using? Why not use a custom function rather than edit template files?
March 20, 2013 at 10:41 am #29722angieatcMemberI 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 #29723angieatcMemberOh 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 #29730angieatcMemberI 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 #29743Brad DaltonParticipantThis url should embed the code here otherwise grab the raw version from this link:
March 20, 2013 at 1:34 pm #29777Brad DaltonParticipantMarch 20, 2013 at 3:32 pm #29802angieatcMemberThank 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 #29805Brad DaltonParticipantAndrew Nacin made a video about it pre_get_posts recently http://wordpress.tv/2013/03/15/andrew-nacin-wp_query-wordpress-in-depth/
March 20, 2013 at 5:16 pm #29821angieatcMemberThanks 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 #31377Noe GarciaMemberHello - 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' => 5, 'feature_image_size' => '0', 'feature_image_class' => 'post-image', 'feature_content_limit' => 0, <strong>'category__not_in' => '5',</strong> 'grid_image_size' => 0, 'grid_image_class' => 'alignnone', 'grid_content_limit' => 1500, 'more' => __( '[Read more]', 'minimum' ), ) ); } else { genesis_standard_loop(); } }
March 26, 2013 at 7:28 pm #31439Brad DaltonParticipantThe 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
April 1, 2013 at 6:58 pm #32543TerenceMemberBrad,
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.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.