WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Daily posts with date-based pagination (5 posts)

  1. aravindajith
    Member
    Posted 2 years ago #

    I am working a news site kind-of website. I have a 'daily news' page which lists all of today's posts with next & previous links to paginate though. The next and previous pages are supposed to display posts published in next and previous days respectively. But I couldn't find any solution to paginate it on date-basis.
    Is there any way to crack it?

    Thanks in advance for the help :)

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    I don't think a normal worpress query can do this. You can try and do it with php. example (above the loop): http://pastebin.com/ZYLxtkQy

    https://codex.wordpress.org/Function_Reference/WP_Query#Time_Parameters

  3. aravindajith
    Member
    Posted 2 years ago #

    Thanks keesiemeijer :)
    Tried some tricks in PHP but couldn't make it work the way we wanted. Got to try your method.

  4. keesiemeijer
    moderator
    Posted 2 years ago #

    This is even better: http://pastebin.com/DXvaVTnX
    If you need daily pagination. This way you always get the next daily posts (even if you didn't post every day). You can even do this within a category if you give the $category variable a category ID. Use it before a loop.

  5. aravindajith
    Member
    Posted 2 years ago #

    Wow! It's working perfectly! Thanks a ton keesiemeijer!! :)

Topic Closed

This topic has been closed to new replies.

About this Topic