Skip to content
Permalink
Browse files

WP-r44338: Correctly show post type hierarchy in admin (#333)

In https://core.trac.wordpress.org/changeset/44185, a bug was introduced where hierarchical post types would not display in the correct default order (hierarchically).

This was caused by a `! isset()` check, which returned `false` after https://core.trac.wordpress.org/changeset/44185, causing the correct default value to not be applied. This switches that conditional to use an `empty()` check, ignoring the new empty string assignment that was added to prevent a PHP notice when `compact()` is called.

WP:Props davidbinda.
Fixes https://core.trac.wordpress.org/ticket/45711.

Conflicts:
src/wp-admin/includes/post.php
----
Merges https://core.trac.wordpress.org/changeset/44338 / WordPress/wordpress-develop@47584c7 to ClassicPress.

See #263.
  • Loading branch information...
Mte90 authored and nylen committed Jan 28, 2019
1 parent ce080b2 commit 5ba06a7fad28bc075f4d12320728f7ed9a71bb4d
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/wp-admin/includes/post.php
@@ -1086,10 +1086,10 @@ function wp_edit_posts_query( $q = false ) {
$query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
// Hierarchical types require special args.
if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) {
$query['orderby'] = 'menu_order title';
$query['order'] = 'asc';
$query['posts_per_page'] = -1;
if ( is_post_type_hierarchical( $post_type ) && empty( $orderby ) ) {
$query['orderby'] = 'menu_order title';
$query['order'] = 'asc';
$query['posts_per_page'] = -1;
$query['posts_per_archive_page'] = -1;
$query['fields'] = 'id=>parent';
}

0 comments on commit 5ba06a7

Please sign in to comment.
You can’t perform that action at this time.