• Resolved shafee85

    (@shafee85)


    Hello,

    I have looked through the support forum but couldnt find a clear answer for my problem.

    I am using the query_posts command within a category. the code is as follows,

    <?php query_posts('cat=53&showposts=1'); ?>
       <?php if ( have_posts() ) : ?>
       <?php while ( have_posts() ) : the_post(); ?>

    Now the category displays the most latest post on the page as i want it to. No problem there. However, there is no way of viewing the older post for this particular category (since only the latest one is displayed).

    How can i add a link like OLDER ENTRIES to this page and make them link to the rest of the posts? Would appreciate any help.

    Thank you for reading.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try adding this code after the endwhile statement further down the page

    <div class="navigation">
    	<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    	<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    </div>
    Thread Starter shafee85

    (@shafee85)

    Thank you very much for your post.

    Inserting stvwlf’s code shows the older entries/ newer entries link. but it loads the same article page that im on.

    E.g. i inserted this code to category id 53 (mydomain.com/?cat=53). when the above code is inserted i get the older entries link at it links as mydomain.com/?cat=53&paged2

    when clicked it shows the same page as /?cat=53. What do i need to do to make this work? Please help

    Note: I am using 2 query_post loops within the page. Could this be causing the problem?

    You need to change your query_posts statement to add paging code,
    like this:

    `<?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts(“cat=53&showposts=1&paged=$paged”); ?>`

    That should resolve it. The double quotes on query_posts are now necessary.

    Thread Starter shafee85

    (@shafee85)

    Thank you very much stvwlf. Your piece of code works perfectly 😀 Cant thank you enough.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query_posts function and Older entries within a category’ is closed to new replies.