WordPress.org

Ready to get started?Download WordPress

Forums

Admin Interface Reverse Chronological Order (4 posts)

  1. Ellis Benus
    Member
    Posted 5 years ago #

    I need to have the administrative interface display the posts in reverse chronological order, oldest to newest.

    The website which visitors see, DOES NOT need to display this way.

    I searched inside the wp-admin directory for the command which lists the posts for an &orderby= query option, but came up with nothing.

    Thank You in advance for any assistance.

  2. Ellis Benus
    Member
    Posted 5 years ago #

    I actually figured this out shortly after posting...

    Go to: wp-admin/includes/post.php

    Scroll down to line number 513

    You are looking for a block like this:

    if ( 'pending' === $q['post_status'] ) {
         $order = 'ASC';
         $orderby = 'modified';
    } elseif ( 'draft' === $q['post_status'] ) {
         $order = 'DESC';
         $orderby = 'modified';
    } else {
         $order = 'DESC';
         $orderby = 'date';
    }

    In the final else {} Change:

    $order = 'ASC';

    to:

    $order = 'DESC';

    That's it! When you are done the block should look like this:

    if ( 'pending' === $q['post_status'] ) {
         $order = 'ASC';
         $orderby = 'modified';
    } elseif ( 'draft' === $q['post_status'] ) {
         $order = 'DESC';
         $orderby = 'modified';
    } else {
         $order = 'DESC'; /* used to be ASC */
         $orderby = 'date';
    }
  3. tomontoast
    Member
    Posted 5 years ago #

    Ok you need to open up wp-admin/includes/post.php
    On line 771 there is a function called function wp_edit_posts_query()
    On line 794 there is

    if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) {
              $order = 'ASC';
              $orderby = 'modified';
          } elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) {
              $order = 'DESC';
              $orderby = 'modified';
          } else {
              $order = 'DESC';
              $orderby = 'date';
          }

    replace the DESC's with ASC's to look like

    if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) {
              $order = 'ASC';
              $orderby = 'modified';
          } elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) {
              $order = 'ASC'; //used to be DESC
              $orderby = 'modified';
          } else {
              $order = 'ASC'; //used to be DESC
              $orderby = 'date';
          }

    You can also on line 805 edit the number of posts displayed per page
    wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby");

    I hope that helps!

  4. tomontoast
    Member
    Posted 5 years ago #

    Oops I posted this without checking to see if anyone else had posted. Anyway we arrived at the same solution which is reassuring!

Topic Closed

This topic has been closed to new replies.

About this Topic