• I love the default way that WordPress displays the initial featured image a bit larger at the top of the page and then displays three horizontal columns beneath it. But how can I tweak the code in the php file to query and return only a particular category on the front page instead of recent posts? I want to use some sort of code like this…

    <?php
    query_posts(‘showposts=4&cat=3’);
    while(have_posts())…;
    ?>

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter awhill00

    (@awhill00)

    Found it…

    Place this code in functions.php to cause the home page to display posts only from one category. Category is ‘123’ in example below. Works great!

    function my_home_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( ‘cat’, ‘123’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘my_home_category’ );

Viewing 1 replies (of 1 total)

The topic ‘Magazine Basic by Category’ is closed to new replies.