Change Pages Link to Display Published Pages Only

[ad_1]

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' );
[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads