WordPress.org

Ready to get started?Download WordPress

Forums

Specific Category on Home page (2 posts)

  1. jonesy13
    Member
    Posted 1 year ago #

    Hi Everyone,

    On a new WordPress site, the Home page is set to 'recent posts' - I would like it to display posts from a specific category ONLY. I know I could set a menu item up that is associated with a specific category and call that the Home page but then I would lose the home page template design. Is there a way to just set the Home page to display posts from a specific category only?

    Thanks for any input!
    Judi

  2. Mayeenul Islam
    Member
    Posted 1 year ago #

    Yes, it's a very common question, you can get many solution by googling it.
    Anyways, it's a query_posts() function, you need to use for it in your theme's index.php.

    <?php
    //it will query for a category which id is 3 and display only 5 posts of that category
    query_posts( 'cat=3&showposts=5' );
    while ( have_posts() ) : the_post()
    ?>

    and after content template
    <?php end while; ?>

    to show a specific quantity of posts (i.e. 5) of that category use:
    query_posts( 'cat=3&showposts=5' );

    P.S.: You can see category ID by hovering your mouse on any category in Posts > Categories in admin panel.

Topic Closed

This topic has been closed to new replies.

About this Topic