Hide Dashboard Page in WP Admin for All Users

This Snippets Hides the Dashboard Page in the WP Admin!

Sometimes you want to hide a page from the WordPress admin pages section to keep it from being seen or edited by your clients, or other users of your website. And if you’re using the Divi Dashboard Welcome plugin then you may want to hide the Divi Dashboard Welcome Screen page, so that your custom WordPress Dashboard layout doesn’t get ruined by a curious client!

In this tutorial we’re going to show you how to hide a WordPress page from the pages section in WP Admin from ALL users, including admin. If you’re looking to hide a page for all users except admin, then you’ll want to check out this article here.

We’ll be talking about hiding the Divi Dashboard Welcome page, but this code can be applied to any page that you want to hide.

The first thing you’ll need to do, is figure out the page ID of your Divi Dashboard Welcome Screen page. To do this, navigate to the Pages section of your website, then click on the “Divi Dashboard Welcome Screen” page. Once the page has loaded, click on the URL bar, and copy the number that comes after “post=”. The URL will look something like this: /wp-admin/post.php?post=609&action=edit — and 609 is the post ID in this example.

Next, copy and paste the below snippet into the functions.php file of your active child theme:

Next, change 609 in the snippet above to whatever your post ID is, and you’re done!

Hide Dashboard Page in Admin for All Users

add_filter( 'parse_query', 'ts_hide_pages_in_wp_admin' );
function ts_hide_pages_in_wp_admin($query) {
    global $pagenow,$post_type;
    if (is_admin() && $pagenow=='edit.php' && $post_type =='page') {
        $query->query_vars['post__not_in'] = array('609');
    }
}