Hide Dashboard Welcome Screen Page in Admin
This Snippets Hides the Page for Non-Admin Users!Sometimes you need to hide a page in the WordPress admin to keep clients or other users of your website from being able to see or edit the page. And if you’re a user of Divi Dashboard Welcome, then you very well may want to hide the Dashboard page to keep the custom Dashboard layout from getting ruined!
In this tutorial, we’ll show you how to hide the Dashboard page in the WordPress admin Pages list from all users, including admins. If you’d like to hide the page from all users except admins, then you’ll want to take a look at this article instead. We’ll specifically be talking about hiding the Divi Dashboard Welcome Screen page, however this tutorial applies to any page you’d like to hide.
The first thing you’ll need to do, is figure out the page ID of your Divi Dashboard Welcome Screen page (or the page you’d like to hide). 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:
Hide Dashboard Page for All Users Except Admins
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');
}
}
If your post ID is 609, then you’re done! If your post ID is something different than 609, then be sure to replace 609 in the code snippet with your actual post ID.