Limiting home page blog post category

Discussion in 'StartPoint Business One Page WordPress Theme' started by kbarnold, Mar 3, 2014.

Thread Status:
Not open for further replies.
  1. kbarnold

    kbarnold Member

    Joined:
    Dec 27, 2013
    Messages:
    62
    Likes Received:
    4
    Is it possible to limit the home page blog posts to a single post category? I don't want every new post to show on the home page automatically, only certain types of posts. Thanks.
     
  2. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
    Hello,

    Go to front-page.php present in your theme directory and replace current code
    Code:
     <?php query_posts('showposts='.$thelimit.''); if (have_posts()) : while (have_posts()) : the_post(); ?>
    with code given below
    Code:
     <?php
    $args = array(
    'category_name'=>'ENTER YOUR CATEGORY NAME HERE'
    );
    $query = new WP_Query($args);
    ?>
     
    <?php query_posts('showposts='.$thelimit.''); if (have_posts()) : while ($query->have_posts()) : $query->the_post(); ?> 
    Check image for reference

    2014-03-03_1346.png


    Thanks & Regards
    Gourav Shrivastava
     
  3. kbarnold

    kbarnold Member

    Joined:
    Dec 27, 2013
    Messages:
    62
    Likes Received:
    4
    Thanks, that worked fine.
     
Thread Status:
Not open for further replies.

Share This Page