• Hi

    This may be a question that is asked alot and I spent about 2 hrs trying to figure it out on my own with no results.

    I have a blog using the Sunspot theme. It is a blog about my collecting of a series of books. Each book in the series has its own page. there are over a hundred book pages and I want to add a navigation link at the bottom of each book page so a visitor can just click on it to go to the next book page.

    so if he/she is on say.. book 1, then at the bottom of the page it will show a link to book 2, book 3, book 4 etc across the bottom of the page.

    as the person goes to the next book page, so say book 2, then the bottom will show:

    book 1, book 3, book 4, book 5 etc across the bottom

    basically its like any other website that has the naviagation with:

    Page 1,2,3,4,5

    hope someone can help, and please forgive me if I am missing something quite obvious

    my website is https://www.nclcollecting.ca

    Scott

Viewing 3 replies - 1 through 3 (of 3 total)
  • Maybe this plugin can do it for you:
    https://www.ads-software.com/plugins/links-shortcode/

    Otherwise you could write you own shortcode handler, the API is here:
    https://codex.www.ads-software.com/Shortcode_API

    OR you could write a custom page template for your book pages. It would be based upon the usual page.php handler, with the addition of extra DIV elements, one for prior book, one for subsequent. They would have css styling to float to the bottom left and bottom right corners of the contents div. Some php code would workout which book (p=number) links to put in each.

    PS: If you are not using a child theme, now is a good time to start.

    Thread Starter Scottbdoug

    (@scottbdoug)

    Hi Ross,

    I looked into the two links in your post and i’m a bit lost on what they do.

    here is more precisely what I would like and if I have to type the code into the page I will do it…

    the books are numbered N1 to N196,
    So that’s 196 books each with their own page

    at the bottom for each page will be:

    Page: NCL1 NCL2 NCL3 NCL4 …Next >

    and it moves along as you go further along the pages with “< Previous” added at the beginning , until you reach N196 which will then loop back to N1.

    Do I need to type that out on each page, then individually add the links or is there a way in wordpress that will add this automatically to the pages?

    With my posts its automatically done with a Previous and Next links that are automatically generated.

    I am not versed in any professional way with wordpress of html but I can learn.

    Scott

    Do I need to type that out on each page, then individually add the links or is there a way in wordpress that will add this automatically to the pages?

    To do it automatically, you need to be able to put code into the page template which can use the WordPress page id (the p=number), and turn it into your book number (your NCL<number>). If you can do this, then it could be done automaticall.

    On the other hand, if the above is too tricky, and since it (ONLY!) involves manual edits on 196 pages (if it were thousands you couldnt do this),

    FROM the API
    Here’s a trivial example of an enclosing shortcode:

    function caption_shortcode( $atts, $content = null ) {
    return ‘<span class=”caption”>’ . $content . ‘</span>’;
    }
    add_shortcode( ‘caption’, ‘caption_shortcode’ );

    When used like this:

    [caption]My Caption[/caption]

    Using a scheme like this, you edit each book page, say this is book 18 and you want to link to books 16,17,19,20 you would add a shortcode [booklink]16:145 17:190 19:161 20:162[/booklink]

    Php code in the booklink shortcode function would produce output like:

    <div class="bklink"><a href="/?p=145">NCL16</a>
    <a href="/?p=190">NCL17</a>
    <a href="/?p=161">NCL19</a>
    <a href="/?p=162">NCL20</a></div>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Page navigation’ is closed to new replies.