Hide posts and pages within the admin from users

I have had a few projects that required me to create a page that is for template use only. I may need to add shortcode or something to the page. Now since I don’t want my client to edit this page and possibly break things I hide the pages. Adding this snippet to the functions.php of your wordpress theme will allow you to add id’s for each of the posts or pages you wish to hide.

 

 

<?php
add_action('admin_head', 'hide_posts_pages');
function hide_posts_pages() {
global $current_user;
get_currentuserinfo();
If($current_user->user_login != 'admin') {
?>
<style>
#post-10, #post-11, #post-12, #post-13, #post-14{
display:none;
}
</style>
<?php
}
}
?>

Leave a comment