Home page issue

Mauer Themes Support Storyteller Home page issue

This topic contains 3 replies, has 2 voices, and was last updated by  Paul 2 years, 11 months ago.

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

    dzukis
    Participant

    Hello Support,

    I just have one issue!. I want to set one certain category showing on home page (3 columng grid layout), not latest posts. How I can do that? I tried to edit query_posts to content_grid_3_cols.php and it works, but breaks layout and show home page very similar as category page (no big image, no grid below it).

    site: http://www.myscratchpost.com/

    #258

    Paul
    Keymaster

    Hello Dzukis,

    For the front page to show posts from a specific category rather than all latest posts, you can modify the query with pre_get_posts. Here is an example of how to make the front page show posts only from the ‘travel’ category:

    function mauer_frontpage_categories($query) 
    {
    		if ($query->is_main_query() && is_front_page()) {
    				$query->set( 'category_name', 'travel' );
    		}
    		return $query;
    }
    add_action( 'pre_get_posts', 'mauer_frontpage_categories' );

    This code should be placed in functions.php of your theme. Or in a child theme / plugin, which would save it from being overwritten when you update the theme.

    Hope that helps.

    #259

    dzukis
    Participant

    Hello Paul,

    Thank you very much. I tried to edit 3 col grid template with similar query but was unsuccesfull.

    That works!

    Best regards!

    #261

    Paul
    Keymaster

    You’re welcome )

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

The topic ‘Home page issue’ is closed to new replies.