WordPress.org

Forums

Next/Prev Page _not_ Next/Prev Post (6 posts)

  1. lmlm
    Member
    Posted 4 years ago #

    Hello everybody,

    I'm working on a website which uses WordPress pages exclusively (no posts). Is there a proper way to link the Next & Previous Page (not post)? Can anyone help with the right php code? How does the page order (as declared in the admin pages section) affect the code?

    I've been trying different bits of code found on the internet, however none of them seem to be working. I've even searched this forum, but ill i got was people referring to posts or pages of posts, which is not what i'm looking for.

    Thanks a lot!

  2. Samuel B
    moderator
    Posted 4 years ago #

  3. lmlm
    Member
    Posted 4 years ago #

    i have read and tried that many times, however since i am trying to put together a brand new theme, it doesnt work. i read it must be placed within the loop (i am using the default loop.php file from twentyten) and then the code in my sidebar is:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <p><?php wp_link_pages('before=<p>&after=</p>'); ?></p>
    
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    what am i doing wrong? thanks!

  4. Samuel B
    moderator
    Posted 4 years ago #

    try
    'link_before'
    and
    'link_after'

  5. lmlm
    Member
    Posted 4 years ago #

    still no result, this:

    <p><?php wp_link_pages('link_before=&link_after='); ?></p>

    generates and empty paragraph:

    <p></p>

  6. lmlm
    Member
    Posted 4 years ago #

    anyone, please can you help? my current code is

    <?php while ( have_posts() ) : the_post() ?>
    <p>1<?php wp_link_pages('link_before=&link_after='); ?>2</p>
    <?php endwhile; ?>

    and that just returns

    <p>12</p>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags