WordPress.org

Ready to get started?Download WordPress

Forums

extending previous/next post links? (6 posts)

  1. googlebot
    Member
    Posted 3 years ago #

    What I mean is how to have previous and next post links to show more posts, like this assuming we are reading post number 3:

    <<-post#1 <-post#2 | post#4-> post#5->>

    Instead of just the first previous/ next post?

    Would be hard to write some incremental function to do this?

    Thanks

  2. chinmoy
    Member
    Posted 3 years ago #

    use wp-pagenavi plugin

  3. googlebot
    Member
    Posted 3 years ago #

    I know that plugin but I need more control at a theme design level, I was thinking about a custom function.

    To be more specific, I'm getting the excerpt to output as previous/next link but I'm limited to,well, a single previous/next post, while I need at least 2 older posts and 2 newer posts, so that plugin is not of much use in this case but thanks anyway.

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    if it does not exist, you can build it yourself:
    http://wordpress.pastebin.com/KSCEZ8LF

    steps:
    -get post ID of current single post;
    -build array of all post IDs;
    -find position of current post ID in array;
    -get the IDs of the adjacent array positions;
    -get permalinks and titles for these IDs;
    -build the structure and show links;

    EDIT: obviously without the usual parameters of 'next_post_link()' for instance;
    also forgot to add provision for the top end of the list; i.e. for the oldest post links :-(

  5. googlebot
    Member
    Posted 3 years ago #

    That is... perfect!!!
    I've been thinking how to do it but I'm not that proficient with php, you just saved me so much time and provided so much learning material. Thanks

    Enjoy your beer (or coffee) ;-)

  6. ambrosite
    Member
    Posted 3 years ago #

    Sounds like you already found what you needed, but for what it's worth, the 2.0 beta version of my Next/Previous Post Link Plus plugin does something similar:

    http://www.ambrosite.com/blog/seeking-beta-testers-for-nextprevious-post-link-plus-2-0

Topic Closed

This topic has been closed to new replies.

About this Topic