WordPress.org

Support

Support » Plugins and Hacks » Open Order Page by Default for Posts and CPTs

Open Order Page by Default for Posts and CPTs

Viewing 3 replies - 1 through 3 (of 3 total)
  • I managed to get the native support for custom post types (by making them hierarchical), but no luck for the default post type.

    Your ideas are much appreciated. Thanks.

    I use this code to get it working for Pages and Custom Post Types (even if they are not hierarchical but support page-attributes) as this simulates clicking the “Sort by Order” button by default for these page types. I’m not sure what you mean by sorting posts by order since posts do not have order by default or even with this plugin as far as I know.

    function my_default_sort() {
    	//print_r($_GET); //debug to see what you got
    	$post_type = (isset($_GET['post_type'])) ? $_GET['post_type'] : '';
    	if ($post_type) {
    		if ($post_type == 'page' || $post_type == 'custom') {
    			if (!isset($_GET['orderby'])) $_GET['orderby'] = 'menu_order+title';
    		}
    	}
    	//print_r($_GET); //debug to see what you did
    }
    add_action( 'load-edit.php', 'my_default_sort' );

    Hope that helps!
    Andrew

    I think this is an issue in core. See #26752

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Open Order Page by Default for Posts and CPTs’ is closed to new replies.