0

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 specific posts on home page as it is not taking the category attribute.

The main problem is this: by clicking on a particular post link the post doesn’t open on a separate page it redirects to the same page.

1
  • First - Do not alter the core. Second - These links may help you with what you need to achieve.
    – vajrasar
    Commented Feb 4, 2013 at 13:02

2 Answers 2

2

Also using query_posts() is highly discouraged. If you need a second loop, use new WP_Query() or if you want to adjust the main loop then use pre_get_posts. If you home page is not a static page, then this should work regardless of what theme you use. (Goes in functions.php... preferably a child theme if you are working with a framework)

function wpa84417_include_cat( $query ) {
    if ( is_home() && is_main_query() ) {
        set_query_var( 'cat', '33' );
    }
}
add_action( 'pre_get_posts', 'wpa84417_include_cat' );
0

You could also code it this way:

function wpsites_genesis_home_category( $query ) {
    if ( is_home() && is_main_query() && !is_admin()) {
        query_set( 'cat', '33' );
    }
}
add_action( 'pre_get_posts', 'wpsites_genesis_home_category' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.