WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Reversing the order of the 'Recent Posts' widget (3 posts)

  1. DylanR
    Member
    Posted 1 year ago #

    Attempting to Google this has broken my brain, but I ain't too proud to beg.

    Hi all, I'm looking for a way to reverse the ordering of the default WP Recent Posts widget. Currently, the latest post is shown at the top of the widget. I want this to be reversed so that the oldest post shows first.

    To give this some context (I'm afraid I must deny you seeing the patient, visiting hours have not yet begun), I have a widget that shows upcoming events using future posts dispensed by the recent posts widget.

    Once a post is published, it is removed from the widget

    So what I want is for the widget to show the 5 most imminent posts to be published, in descending order (1st Jan, 2nd Jan, 3rd Jan, etc.)

    Is this at all possible?

    I don't want this to be universal for my site though, just the widget. There will be a page in which the events MUST be shown in reverse-chronological order

    Thanks in advance!

  2. DylanR
    Member
    Posted 1 year ago #

    Hi Again, all

    Just in case anyone finds this with the same issue:

    My solution was to add the following code to my WP_Query:

    'orderby' => 'date', 'order' => 'ASC'

    I added this in the array for query arguments

  3. IsomAdvanced
    Member
    Posted 1 year ago #

    DylanR, I want to do the same thing, but I don't understand what a WP_Query is. I'm new to programming, can you point me in the right direction? Is is a file or an array in a file, and if so what file? Thank you for your time and knowledge.

Topic Closed

This topic has been closed to new replies.

About this Topic