Support » Plugins » Posts from category on main page

  • Resolved blaze1

    (@blaze1)


    Hi,
    I would like to display posts only from one specified category on main page. Is it possible in any way?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello

    Yes just run query_posts above the loop.

    <?php query_posts('cat=#'); ?>

    cat=# should be changed to the cat you wish to display.

    This should go in index.php (or home.php if you are using it) like so:

    <?php if (have_posts()) : ?>
    
    <?php query_posts('cat=#'); ?>
    
    <?php while (have_posts()) : the_post(); ?>

    Hope it helps. 🙂

    Thank You very much, it works! but… when I click “older entries” nothing happens. Page reloads, then I see also link “newer entries”, but posts are the same. It’s not so important to me but it could be ok:)

    Ok, I’ve spend some time in reading docs, and I found it.
    Because if we use query_posts() GET variables doesn’t work, and it should be define in query. So I made that query:

    <?php
    $query='cat=1&paged='.$paged;  // $paged is global variable
    
    if (have_posts()) :
    	if (is_home()) {
    		query_posts($query);
    		}
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Posts from category on main page’ is closed to new replies.