Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi
    My template doesn’t seem to have the code for the Previous Posts and Next posts link. Are there any instructions on how to add these links to the existing code?
    Thank you!

    Thread Starter datingexpert

    (@datingexpert)

    Ok the standard one is like the following:

    <div class=”navigation”>

    <div class=”alignleft”><?php next_posts_link(‘« Previous Entries’) ?></div>

    <div class=”alignright”><?php previous_posts_link(‘Next Entries »’) ?></div>

    </div>

    You will need to set the style of how you want your navigation to look like in the style sheet. Some may prefer to attach an image like arrows instead of using physical text like Previous Entries.

    Hope you can get it working, for this one is tested to work successfully, so now I am seriuosly thinking it’s gotta do with my template.

    What plugins do you have active? The code you posted is exactly what I’m using (2.0.4) and everything is working just fine. There are a few other functions you might want to glance at, though I’m not sure if they’ll work where you want them to.

    Try either making post singular (previous_post_link instead of previous_posts_link) or getting rid of link (previous_post instead of previous_posts_link). Here’s some relevant info:
    http://codex.wordpress.org/Next_and_Previous_Links
    http://codex.wordpress.org/Template_Tags/previous_post_link

    I’m having the same problem…something is not working with my template, although I’ve used pretty much the same code found in the documentation.

    I’ve tried 2 ways:

    <?php next_posts_link('&laquo; posts mais recentes') ?>&nbsp;&middot;&nbsp;<?php previous_posts_link('posts mais antigos &raquo;') ?>

    and

    <?php posts_nav_link('&nbsp;&middot;&nbsp;','&laquo; posts mais recentes','posts mais antigos &raquo;'); ?>

    Both of them shows the “previous” and “next” links, and creates URLs like “mydomain.com/page/3” “mydomain.com/page/2”.

    But the content of each is basically the same as the main page “mydomain.com”.

    I’m not sure what’s going on…tryed to change the template to the default one and it worked. Moved back to my, didn’t work again.

    I put the template here, in case anyone could help:
    http://www.feiramoderna.net/blog_template.txt

    I’m not even sure if this is a problem with this file or not. 😛

    I’m using WP 2.2.1, I don’t have any plugins activated, and my site leaves here: http://www.feiramoderna.net

    Update: this page template I’ve copied is not the index.php file. I use another page template for the blog.

    I have 3 main sessions on the site, each one should display only the posts related to a certain category. So, I’ve used a script to “filter” the posts, before the loop starts.

    <?php query_posts("cat=-25,-35"); ?>

    I’ve tested removing this line, and renaming the template file as index.php (also removing the first lines of the page, where I define the template name). The “previous / next entries” worked fine.

    So, I assume there is a conflict between this query I’m doing not to show the posts of some categories, and the feature for creating the pages after I reach the limit os posts per page defined in the “Options” panel of the admin area.

    I really need to have these 3 sessions, and to exclude some posts from the list on each page, according to the category they belong. But seems that the “next/previous” have some difficulties to understand me! 🙂

    Anythoughts on how I could fix this?

    Moshu provided the answer! 🙂

    http://wordpress.org/support/topic/87020?replies=4#post-444035

    Instead of using:
    <?php query_posts("cat=-25,35"); ?>

    Use:

    <?php $page = (get_query_var('paged'))
    ? get_query_var('paged') : 1;
    query_posts("cat=-25,-35&showposts=10&paged=$page");
    ?>

    It works!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Previous Entries navigation not working’ is closed to new replies.