• Resolved Arnoud

    (@derice)


    I would like to add a “Previous” and “Next” link below my multi paged posts/pages.

    Currently it’s like this:
    Pages: 1 2 3 4 5 6 7 8 9
    Used code:
    <?php link_pages('<p><strong>' . __('Pages:') . '</strong> ', '</p>', 'number'); ?>

    I would like it to look like this:

    << Previous Page | 1 2 3 4 5 6 7 8 9 | Next Page >>
    (Current page should be in bold)

    I’ve found this article:
    http://codex.wordpress.org/Styling_Page-Links
    But I can’t seem to make it work.

    Is there someone who would like to help me out with this?

Viewing 15 replies - 1 through 15 (of 25 total)
  • Roy

    (@gangleri)

    This plugin does most of what you want, otherwise you can use it as starter perhaps.

    Thread Starter Arnoud

    (@derice)

    This plugin doesn’t apply for posts itself.
    I need to modify the “page.php” & “single.php”.

    This plugin is for the archive.php, index.php or search.php files.
    I did try to replace the line of code I mentioned above with the code provided in the installation document of the plugin you suggested but it didn’t go for it.

    In short, replacing:
    <?php link_pages('<p><strong>' . __('Pages:') . '</strong> ', '</p>', 'number'); ?>
    with:

    <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?>

    and the plugin doesn’t work.
    No page numbers are displayed at all below a post.

    Roy

    (@gangleri)

    That’s weird. I don’t use it myself, but many people do. Perhaps you could ask the author what’s wrong. Otherwise, the code might inspire you in making the thing happen yourself?

    [Edit], you’re right it works only at the pages with more posts. Understandably too. You can’t use the plugin and its files as a starting point? Apparently it only looks in the section where it is installed, but perhaps you can have it look in the index-file (or so) by default.

    Thread Starter Arnoud

    (@derice)

    I’m affraid that my knowledge of PHP isn’t extensive enough to modify the script.
    I was hoping for a simple solution/plugin.

    It amazes me that there isn’t something like this standard in WordPress.

    Thread Starter Arnoud

    (@derice)

    I’ve managed to create this piece of code:

    <?php link_pages(‘<p>‘ . __(‘Pages:’) . ‘ ‘, ‘</p>’, ‘next’, ‘ Next Page »’, ‘« Previous Page ‘); ?>

    This shows the Previous/Next option at the bottom of a multi paged post.
    However it doesn’t show the page numbers.
    Any idea’s on how to achieve this?

    Thread Starter Arnoud

    (@derice)

    A bit futher, where i really need some help:

    I’ve got these 2 lines of code:

    <?php link_pages(‘<p>‘ . __(‘Pages:’) . ‘ ‘, ‘</p>’, ‘number’); ?>

    <?php link_pages(” . __(‘ ‘) . ”, ”, ‘next’, ‘ Next Page »’, ‘« Previous Page ‘); ?>

    This results in:
    Pages: 1 2 3 4 5 6 7 8 9

    « Previous Page Next Page »

    However I would like it to look like this:

    « Previous 1 2 3 4 5 6 7 8 9 Page Next Page »

    But I doubt that this is possible, worst case I could live with:

    1 2 3 4 5 6 7 8 9
    « Previous Page Next Page »

    Thread Starter Arnoud

    (@derice)

    This last view should look like (can’t edit my post???):

    Row1: 1 2 3 4 5 6 7 8 9 (center aligned)
    Row2: « Previous Page (left aligned) (right aligned) Next Page »

    Does anyone know how to achieve this?
    With a table it doesn’t work because the syntax can’t be broken.

    Also I would like to know if it’s possible to ‘gettext’ the “Next Page” and “Previous Page”. I’ve tried this in the syntax but it’s not accepted.

    Thread Starter Arnoud

    (@derice)

    No one who can help me out on this?
    I can’t imagine that I am the only one with this query!

    hotkee

    (@hotkee)

    How about

    <p><?php previous_post('%', 'Previous Page', 'no'); ?>
    | <?php next_post('%', 'Next Page', 'no'); ?></p>
    hotkee

    (@hotkee)

    And link_pages is depreciated function use wp_link_pages, something like

    <?php wp_link_pages('before=<p>&after=</p>&next_or_number=number&pagelink=page %'); ?>
    Thread Starter Arnoud

    (@derice)

    Hi, the first suggestion you posted (using link_pages) only returns the | symbol. Looks like the code isn’t processed.

    The wp_link_pages code doesn’t seem to accept a combination of
    &next_or_number=next&pagelink=page %
    either of those works fine, but a combination doesn’t…

    Also I can’t seem to style the Previous/Next links to show up all the way on the left and right of the post.

    hotkee

    (@hotkee)

    Try <?php previous_post_link(); ?> and <?php next_post_link(); ?> rather than

    <p><?php previous_post('%', 'Previous Page', 'no'); ?>
    | <?php next_post('%', 'Next Page', 'no'); ?></p>
    Thread Starter Arnoud

    (@derice)

    Those are meant for skipping to the next post. Not for skipping to the next page of a post.

    I did find this, I’m testing with right now:

    <?php
    wp_link_pages(‘before=<div class=”next”>&after=</div>&next_or_number=next
    &previouspagelink=« Previous Page’);
    wp_link_pages(‘before=<div class=”number”>&after=</div>
    &next_or_number=number’);
    wp_link_pages(‘before=<div class=”next”>&after=</div>&next_or_number=next
    &nextpagelink=Next Page »’);
    ?>

    Thread Starter Arnoud

    (@derice)

    Driving me nuts!

    The code above turns into (can’t figure out why!):

    Next Page
    1 2 3 4 5 6 7 8 9
    Next Page

    Should be:

    Next Page
    1 2 3 4 5 6 7 8 9

    WHen I click to the next page, it shows up like:

    Next Page
    1 2 3 4 5 6 7 8 9
    Previous PageNext Page
    (no typo! It really says this!)

    The last page is the only one that shows corretly…

    1 2 3 4 5 6 7 8 9
    Previous Page

    I feel like I’m almost there, but it’s still not turning out the way I want it to, any tips/suggestions?

    hotkee

    (@hotkee)

    Well if you feel you have something that nearly works then do some styling to make it appear to the left and right.

    Have a look at the Default theme for wordpress which has something like this

    <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>

    You will need to do the same styling (i.e. <div class=”navigation”>) to make your thing work as you want it to.

    If you are not good with CSS, get someone else to do it for you.

Viewing 15 replies - 1 through 15 (of 25 total)

The topic ‘Previous/Next below posts/pages’ is closed to new replies.