Wordpress - How to disable posts and use pages only

You can simply hide the posts menu by adding the following to your functions.php file:

function remove_posts_menu() {
    remove_menu_page('edit.php');
}
add_action('admin_menu', 'remove_posts_menu');

I would recommend you to leave the post only for the admin user... literally the "admin", and create another user to manage the page, so I case you need it in the future for scalability you can go back to it with your admin account.

Just add the following code to your functions.php

 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');

Have you thought about just renaming "Posts" to something like "News" ? So that the user (yourself or a client) could still post news, press releases, articles, etc. to prevent stagnant content on the site.

It's quite simple to do. Just pop this in your functions file.

function change_post_menu_label() {
    global $menu;
    global $submenu;

    $menu[5][0] = 'News';
    $submenu['edit.php'][5][0] = 'News';
    $submenu['edit.php'][10][0] = 'Add Article';
    $submenu['edit.php'][15][0] = 'News Categories'; // Change name for categories
    $submenu['edit.php'][16][0] = 'News Article Tags'; // Change name for tags
}

function change_post_object_label() {
    global $wp_post_types;

    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'News';
    $labels->singular_name = 'News';
    $labels->add_new = 'Add Article';
    $labels->add_new_item = 'Add Article';
    $labels->edit_item = 'Edit Article';
    $labels->new_item = 'News Article';
    $labels->view_item = 'View Article';
    $labels->search_items = 'Search News';
    $labels->not_found = 'No Articles found';
    $labels->not_found_in_trash = 'No Articles found in Trash';
}
add_action( 'init', 'change_post_object_label' );
add_action( 'admin_menu', 'change_post_menu_label' );

And now you can have news that everyone can benefit from. Hope this helps!

Tags:

Pages