1

In my Admin Panel, I am constantly checking my Posts by state and visitor count via the All Posts link on the lefthand menu bar. My desired URL looks like:

wp-admin/edit.php?post_status=publish&post_type=post&orderby=post_views&order=desc

But the default for this link is just

wp-admin/edit.php

How can I make it so that the default link for my Posts is like the first one?

2 Answers 2

1

This was answered in a previous question:

https://stackoverflow.com/questions/31434373/in-wordpress-how-do-i-set-the-default-admin-sort-order-for-a-custom-post-type-t#answer-31520570

This accepted answer will walk you through how to set up the pre_get_posts callback. That would be my recommendation.

1

Add this to your child theme's function.php:

add_action( 'admin_menu', 'wpse_244328_post_menu' );
function wpse_244328_post_menu() {
    global $submenu;
    $submenu['edit.php'][5][2] = 'edit.php?post_status=publish&post_type=post&orderby=post_views&order=desc';
}

This will change the default value for the Posts menu from:

edit.php

to

edit.php?post_status=publish&post_type=post&orderby=post_views&order=desc
2
  • I love this answer except that when I implement it, it makes my Posts submenu stop working. Is there a way to implement this but still have the submenu appear? Oct 29, 2016 at 17:09
  • Updated the code, submenu will be still be available now. Oct 29, 2016 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.