Custom homepage not displaying proper category

Community Forums Forums General Discussion Custom homepage not displaying proper category

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  Stewart 1 year, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46876

    denimyers
    Participant
    Post count: 1

    Hello,

    I’ve ruled out any theme issues, but I’m still having a problem with getting my home page to display the content I want. I’ve tried two methods that have worked for me on other WordPress sites in the past:

    1. Add a custom field to the page “query_args” and set that to “cat=4″ which is the category ID I want to display on the homepage

    2. Added this function to  my home.php page:

    function cd_homepage_posts( $query ) {
    if ( is_home() && is_main_query() ) {
    set_query_var( ‘cat’, ’4′ );
    }

    }

    add_action( ‘pre_get_posts’, ‘cd_homepage_posts’ );

    genesis();

    The result I get is that all categories are displayed, not just category 4. Is there something I’m missing?

    Any help is greatly appreciated!

    Thanks!
    Denise

    #46927

    Stewart
    Participant
    Post count: 156

    Hi Denise,

    Try this and see if it works for you.

    function cd_homepage_posts( $query ) {
    		if( $query->is_main_query() && $query->is_home() ) {
    		$query->set( 'cat', '4' );
    		}
     	}
    	add_action( 'pre_get_posts', 'cd_homepage_posts' );

    Hope this helps


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

    #47805

    denimyers
    Participant
    Post count: 1

    Hi Stewart,

    Thank you for your reply. Unfortunately that didn’t work either, but we decided to use the Genesis Featured Widget Amplified for the time being.

    Thanks again!

    #47807

    Stewart
    Participant
    Post count: 156

    Hi Denise,

    Strange that did not work, but glad you got it sorted.

    Good Luck
    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

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

You must be logged in to reply to this topic.