Change Pages Link to Display Published Pages Only

How to Change Pages Link to Display Published Pages Only

in WordPress Admin
Google+ LinkedIn

In previous articles we have seen ways to remove submenu items and add link to all options in WordPress admin, In this article we will see how to change pages link in WordPress menu to display published pages.

By default, Pages link in WordPress admin dashboard shows a list of all pages, no matter what their publishing status is. If you want to display published pages, you can filter your page list by visiting “Published” tab. It should not be a major problem for a regular blogger but if you have a lot of drafts then it would be difficult for you to identify publish pages on default pages list. Although you can always visit Published tab to display published pages but getting only to display them requires another click and full reload.

WordPress provides a very nice way to change default dashboard menu links. With the help of WordPress action admin_menu, we can change the default behavior of menu links and force WordPress to display list of published pages only.

To display published pages by default on pages link, simply paste this code snippet in your functions.php. You can then visit “All” tab to see full list of pages.

// change page link to display published pages only
function wcs_change_admin_page_link() {
    global $submenu;
    $submenu['edit.php?post_type=page'][5][2] = 'edit.php?post_type=page&post_status=publish';
add_action( 'admin_menu', 'wcs_change_admin_page_link' );

If you want to achieve the same for post link in admin dashboard then use following code snippet instead.

// change post link to display published posts only
function wcs_change_admin_post_link() {
    global $submenu;
    $submenu['edit.php'][5][2] = 'edit.php?post_status=publish';
add_action( 'admin_menu', 'wcs_change_admin_post_link' );

Share the love

If you like this snippet, share it with others!

2 Replies on "Change Pages Link to Display Published Pages Only"

  1. CEdwards

    I know this was published in 2014, but it still works perfectly. I also added it for portfolio listing by editing the page script and just changing each “page” reference to “portfolio”.

    I do think it would be clearer though to clarify the title –
    “How to Change Default page and post views to Published vs All”
    Some people may misinterpret the “Public Only”

    Thanx much for this!

  2. Mark

    Please update this page, what you have does not work today in WordPress 5.2.2

    I look forward to the update!

Leave a Reply

Your email address will not be published. Required fields are marked *