Support » Fixing WordPress » Using posts_nav_link in a non standard template

  • I was wondering if it was possible to use posts_nav_link in a template page that is not standard (i.e index.php, category.php…)
    something like this:
    $posts = get_posts('numberposts=5');
    foreach($posts as $post) :
    "><?php the_title(); ?>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>
    <?php posts_nav_link(' — ', __('« Previous Page'), __('Next Page »')); ?>

    I’ve tried this of course but it does not seem to work.
    Are there alternatives that cam be used?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Is this a Page template? In that case it will not work: Pages are meant to display ONE single content and (out of the box) there is no next/prev navigation for them.

    Yes, my question regards Page Templates.
    I was wondering if anybody knew of a hack or a workaround
    that permitted me to have on a Page Template something similar to prev/next seeing that I using a simple foreach loop I can show within that Page a limited number of posts at a time.
    I’m one of the many who would like to use WordPress as a light CMS and each time that I try other platforms I come back to WordPress.

    I am wondering the prev/next could be possible or if I am going on a dead end street.

    Template_Tags/wp_link_pages give that a try? I’m just throwing it out there, I’ve not tried it myself.

    The wp_link_pages is a good idea however the problem remains.
    I think that it’s because both posts_nav_link and wp_link_pages can only be used within the Loop and the Loop does not work in Page Templates.

    So at the moment I think that I will try to resolve the issue hard coding a next link.

    Thank you for your ideas.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using posts_nav_link in a non standard template’ is closed to new replies.