WordPress.org

Support

Support » Plugins and Hacks » Hacks » extending previous/next post links?

extending previous/next post links?

  • 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

Viewing 5 replies - 1 through 5 (of 5 total)
  • use wp-pagenavi plugin

    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.

    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 🙁

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

    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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘extending previous/next post links?’ is closed to new replies.
Skip to toolbar