Default sorting posts of custom post types with the `hierarchical`
-
Hi there,
Custom post types with the
hierarchical
argument value set totrue
list posts in the order that the older ones come first in the admin post listing table.To reproduce the problem,
1. Create a test custom post type with the below code.
new Tests_CustomPostType; class Tests_CustomPostType{ public function __construct() { add_filter( 'init', array( $this, 'testPostType' ) ); } public function testPostType() { $labels = array( 'name' => _x( 'Books', 'Post type general name', 'textdomain' ), 'singular_name' => _x( 'Book', 'Post type singular name', 'textdomain' ), 'menu_name' => _x( 'Books', 'Admin Menu text', 'textdomain' ), ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'book' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => true, 'menu_position' => null, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ), ); register_post_type( 'book', $args ); } }
2. Create several posts of that
book
post type.
3. Go to Dashboard -> Books.
4. You’ll see the posts listed in the reverse date order.I would suggest sorting posts normally as it looks inconsistent.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Default sorting posts of custom post types with the `hierarchical`’ is closed to new replies.