[Support request] Previous 5 posts from current post

Home Forums Support [Support request] Previous 5 posts from current post

Home Forums Support Previous 5 posts from current post

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #610900
    Anil

    Hi

    How to get previous 5 posts from the current post in the sidebar widget ?

    I would appreciate your help.

    Regards.

    #611122
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I’m not too sure what you mean by previous posts from the current post. Can you explain a bit more?

    #611296
    Anil

    I mean

    you are reading this post at this url
    https://generatepress.com/forums/topic/previous-5-posts-from-current-post-widget/

    Can I display 5 posts — posted just before this post — below this post or in a widget in the sidebar?

    #611581
    Tom
    Lead Developer
    Lead Developer

    You should be able to use a plugin like this: https://wordpress.org/plugins/recent-posts-widget-extended/

    There’s an offset option, and should even be an option to ignore the current post.

    #611599
    Anil

    Thanks Tom, but it is just showing only recent posts….

    I want 5 posts descending from current post, i.e.

    CURRENT POST

    – Title and link of previous post
    – Title and link of previous previous post
    – Title and link of previous previous previous post

    I think I need to get help from get_previous_post() in for or while loop…

    <?php
    $prev_post = get_previous_post();
    if (!empty( $prev_post )): ?>
    guid ?>”><?php echo $prev_post->post_title ?>
    <?php endif ?>

    #611863
    Tom
    Lead Developer
    Lead Developer

    Ah, that would likely require some pretty considerable coding.

    I believe the plugin I linked to, and this one (https://wordpress.org/plugins/ultimate-posts-widget/), have an order by date option. However, that wouldn’t make it so they started at the previous post of the one being viewed.

    You might be able to ask in their support forums if there’s a filter you can do to achieve that?

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.