If you are not using default WordPress posts functionality and using only pages or custom post types then you can easily remove the posts section from your admin area dashboard or limit it to website admins.
In this lesson we will provide you PHP fucntions you can either use in your theme’s function.php file or via Code Snippets plugin to limit or disable posts features in WordPress.
How To Disable WordPress Posts?
function remove_posts_menu() {
remove_menu_page(‘edit.php’);
}
add_action(‘admin_init’, ‘remove_posts_menu’);
Once this is activated, it will disable the posts section from admin area dashboard. Great when using custom post types and not the standard WordPress posts.
How To Limit WordPress Posts To Admins?
function remove_menus () {
global $menu;
$user = wp_get_current_user();
if ($user->ID!=1) { // Is not administrator,
$restricted = array(__(__(‘Posts’));
end ($menu);
while (prev($menu)){
$value = explode(‘ ‘,$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){unset($menu[key($menu)]);}
}
}
}
add_action(‘admin_menu’, ‘remove_menus’);
Given snippet simply hides WordPress posts functionality for all other users excluding site administrators.