To display posts from a specific category or categories, you need to add a 'cat' argument to the $grid_args array. StudioPress gives a good introductory tutorial, How to Use the Genesis Grid Loop, on how to set this up.
In the StudioPress tutorial, you are given this example for your home.php.
[php highlight="17"]<?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' => 2,
'feature_image_size' => 0,
'feature_image_class' => 'alignleft post-image',
'feature_content_limit' => 0,
'grid_image_size' => 'grid-thumbnail',
'grid_image_class' => 'alignleft post-image',
'grid_content_limit' => 0,
'more' => __( '[Continue reading...]', 'genesis' ),
'posts_per_page' => 6,
'cat' => '6,7' //enter your category IDs here separated by commas in ' '
) );
} else {
genesis_standard_loop();
}
}
/** Remove the post meta function for front page only **/
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
genesis();[/php]
alex says
So, Travis, this is awesome and works well for me. However, in some cases rather than picking categories to include, you’d rather just exclude a category or two. What’s the syntax to exclude a category?
Alex
lavi says
Hello!
actually i have used this code but my problem is not resolved.
my site has genesis framework and a child theme. i want to show specific category posts on my home page content area. i used the simple post query
query_posts(‘post_status=publish&cat=33&wp_get_recent_posts()’);
in my genesis/lib/structure/loops.php file right above the do_action( ‘genesis_before_post’ );
but it makes no sense .
so at last i used this grid loop but using this i am still unable to show category specefic posts on home page as it is not taking the category attribute.
can u help me that how can i show specific category posts on my home page .
the main problem is this : by clicking on a particular post link the post doesn’t open on a saparate page it redirects to the same page.
can anyone help me regarding this???
lavi says
Hello!
actually i have used this code but my problem is not resolved.
my site has genesis framework and a child theme. i want to show specific category posts on my home page content area. i used the simple post query
query_posts(‘post_status=publish&cat=33&wp_get_recent_posts()’);
in my genesis/lib/structure/loops.php file right above the do_action( ‘genesis_before_post’ );
but it makes no sense .
so at last i used this grid loop but using this i am still unable to show category specefic posts on home page as it is not taking the category attribute.
can u help me that how can i show specific category posts on my home page .
the main problem is this : by clicking on a particular post link the post doesn’t open on a saparate page it redirects to the same page.
can anyone help me regarding this???
Brandon Kraft says
FYI for everyone: This is now superseded by this excellent tutorial by Travis:
https://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/