Make WordPress Core


Ignore:
Timestamp:
08/29/2023 10:03:25 PM (8 months ago)
Author:
joemcgill
Message:

Posts, Post Types: Reinstate missing sort_column options in get_pages().

This fixes an issue introduced in [55569] that broke sort ordering by post_modified_gmt or modified_gmt.

Props david.binda, azaozz, spacedmonkey, flixos90, joemcgill.
Fixes #59226.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r56452 r56490  
    60676067    }
    60686068
     6069    /*
     6070     * Maintain backward compatibility for `sort_column` key.
     6071     * Additionally to `WP_Query`, it has been supporting the `post_modified_gmt` field, so this logic will translate
     6072     * it to `post_modified` which should result in the same order given the two dates in the fields match.
     6073     */
    60696074    $orderby = wp_parse_list( $parsed_args['sort_column'] );
    6070     $orderby = array_map( 'trim', $orderby );
     6075    $orderby = array_map(
     6076        static function( $orderby_field ) {
     6077            $orderby_field = trim( $orderby_field );
     6078            if ( 'post_modified_gmt' === $orderby_field || 'modified_gmt' === $orderby_field ) {
     6079                $orderby_field = str_replace( '_gmt', '', $orderby_field );
     6080            }
     6081            return $orderby_field;
     6082        },
     6083        $orderby
     6084    );
    60716085    if ( $orderby ) {
    60726086        $query_args['orderby'] = array_fill_keys( $orderby, $parsed_args['sort_order'] );
Note: See TracChangeset for help on using the changeset viewer.