Forums

[resolved] Previous/Next below posts/pages (26 posts)

  1. Derice
    Member
    Posted 3 years ago #

    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?

  2. Roy
    Member
    Posted 3 years ago #

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

  3. Derice
    Member
    Posted 3 years ago #

    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.

  4. Roy
    Member
    Posted 3 years ago #

    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.

  5. Derice
    Member
    Posted 3 years ago #

    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.

  6. Derice
    Member
    Posted 3 years ago #

    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?

  7. Derice
    Member
    Posted 3 years ago #

    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 »

  8. Derice
    Member
    Posted 3 years ago #

    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.

  9. Derice
    Member
    Posted 3 years ago #

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

  10. hotkee
    Member
    Posted 3 years ago #

    How about

    <p><?php previous_post('%', 'Previous Page', 'no'); ?>
    | <?php next_post('%', 'Next Page', 'no'); ?></p>
  11. hotkee
    Member
    Posted 3 years ago #

    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 %'); ?>
  12. Derice
    Member
    Posted 3 years ago #

    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.

  13. hotkee
    Member
    Posted 3 years ago #

    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>
  14. Derice
    Member
    Posted 3 years ago #

    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 »');
    ?>

  15. Derice
    Member
    Posted 3 years ago #

    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?

  16. hotkee
    Member
    Posted 3 years ago #

    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.

  17. Derice
    Member
    Posted 3 years ago #

    I rather have something that works before styling.
    Still need to figure out why the Next/Previous don't show up consistant.

    CSS isn't a problem for me, PHP is. ;)

  18. hotkee
    Member
    Posted 3 years ago #

    What is your site url?

  19. Derice
    Member
    Posted 3 years ago #

    The site/page I am working on is:
    http://www.arnoudraeven.nl/?page_id=248

  20. hotkee
    Member
    Posted 3 years ago #

    So this is a page and you are trying to go paginate the pages.

    Why do you need it to be pages, could posts not work for the purpose?

  21. hotkee
    Member
    Posted 3 years ago #

    Also I am seeing something like this

    Volgende Pagina
    1 2 3 4 5
    Vorige PaginaNext Page

    What does Volgende Pagina mean, can you paste your code. Next Page is appearing it seems, not Previous Page.

  22. Derice
    Member
    Posted 3 years ago #

    If you examine the rest of the site, you will see that it exists of mainly travel blogs. These blogs contain a page per day.

    I want to be able to select individual pages (as it is now) and to be able to click on a line of text that states: Previous Page / Next Page.
    This so visitors can navigate easier through the stories, I received some comments on it, people find it tricky to click on just the number to advance to the next chapter.

  23. Derice
    Member
    Posted 3 years ago #

    Volgende Pagina is Dutch, it's translated automatically by gettext & a .mo file.
    (See the language option on the right hand side of the site).

    Volgende Pagina means Next Page
    Vorige Pagina means Previous Page

    Code that is currently generating the page navigation:

    <?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 »');
    ?>

  24. Derice
    Member
    Posted 3 years ago #

    These lines of code are in my template in a file called "page.php"

  25. hotkee
    Member
    Posted 3 years ago #

    Try this, it will work

    <?php wp_link_pages('before=<p>&after=</p>&next_or_number=text&previouspagelink=Previous Page&nextpagelink='); ?>
     | <?php wp_link_pages('before=<p>&after=</p>&next_or_number=number'); ?>|
    <?php wp_link_pages('before=<p>&after=</p>&next_or_number=text&nextpagelink=Next Page&previouspagelink='); ?>

    You will have to style yourself.

  26. Derice
    Member
    Posted 3 years ago #

    Marvellous!
    Thanks so much! :) :)
    You just made my day!!!

Topic Closed

This topic has been closed to new replies.

About this Topic