keepcalculator

06 Numbers and Powers

Remove Default Post Type from Admin Menu WordPress

Card No. 06·70408 · Updated · Standard formula, shown below

To remove the default “Posts” menu from the WordPress admin sidebar, you add a small snippet of code to your theme’s functions.php file or a site-specific plugin. This code uses the remove_menu_page() function to hide the menu item, but it does not delete your posts or prevent them from being displayed on your site.

Why You Might Want to Remove the Posts Menu

WordPress ships with two default content types: Posts and Pages. Posts are meant for time-based, blog-style content, while Pages are for static content like “About” or “Contact.” Many websites—especially business sites, portfolios, or landing pages—never use the Posts feature at all. Yet the Posts menu still appears in the admin sidebar, cluttering the interface and confusing clients who are managing their own site.

Removing the Posts menu can make the admin area cleaner and more focused. It also prevents accidental creation of blog posts when the site is designed to use only Pages or custom post types. This is a common request from developers who build custom WordPress sites for clients.

How the Admin Menu Works

WordPress builds the admin menu dynamically using a system of hooks and global variables. The remove_menu_page() function is part of the WordPress Administration Menu API. It takes a single parameter: the menu slug of the item you want to remove. For the default Posts menu, the slug is edit.php.

The function must be called inside a hook that fires after the menu is registered. The most reliable hook is admin_menu, which runs after all menus are added. If you call remove_menu_page() outside of this hook, it will not work because the menu hasn’t been built yet.

Here is the basic code snippet:

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

Place this in your theme’s functions.php file or in a custom plugin. If you are using a child theme, add it to the child theme’s functions.php so it doesn’t get overwritten when the parent theme updates.

Step-by-Step Instructions

  1. Log in to your WordPress admin dashboard.
  2. Go to Appearance > Theme File Editor.
  3. Select functions.php from the list of theme files on the right.
  4. Add the code snippet at the end of the file, before the closing ?> tag if one exists.
  5. Click Update File.
  6. Refresh the admin page. The Posts menu should disappear from the sidebar.

If you prefer not to edit your theme (which can be risky if you make a mistake), use a plugin like Code Snippets or create a simple site-specific plugin. This keeps your code separate from the theme and makes it easier to manage.

Common Problems and Solutions

Sometimes the code doesn’t work as expected. Here are the most frequent issues:

  • Menu still visible: This usually means the code is not being executed. Check that you placed it in the correct file and that the file is saved. Also, make sure you are using the correct hook (admin_menu).
  • Menu disappears but links break: If you have custom links or widgets that point to the posts archive, they will still work because the posts exist. However, if you try to access edit.php directly, you will get a permission error. This is normal.
  • Posts menu returns after theme update: If you added the code to your main theme’s functions.php and the theme updates, your changes will be lost. Use a child theme or a plugin to avoid this.
  • Submenus still appear: The remove_menu_page() function removes the top-level menu and its submenus. If you only want to remove the submenus (e.g., Categories, Tags), use remove_submenu_page() instead.

Alternative Methods

If you want more control over which menu items appear for different user roles, consider using a plugin like Admin Menu Editor or User Role Editor. These plugins let you hide menu items visually without writing code, and they allow you to show different menus to different users.

Another approach is to use the admin_menu filter to reorder or rename the menu, but for simply removing the Posts menu, the code snippet above is the standard solution.

If you want to remove the Posts menu only for certain users (like editors or contributors) but keep it for administrators, you can wrap the removal in a conditional check:

add_action('admin_menu', 'remove_posts_menu_for_editors');
function remove_posts_menu_for_editors() {
    if (current_user_can('editor')) {
        remove_menu_page('edit.php');
    }
}

Does This Affect Your Website’s Front End?

No. Removing the menu from the admin sidebar only affects the WordPress dashboard. Your posts remain in the database and are still visible to visitors if you have any post-based pages (like a blog page or category archives). The posts are also still accessible via the admin if you navigate to wp-admin/edit.php directly, although the menu will be hidden.

If you want to completely disable the post type, you would need to register a custom post type with show_ui => false or use a plugin that disables it. However, this is rarely necessary. Simply hiding the menu is usually enough to prevent accidental posts.

How to Revert the Change

If you change your mind, simply remove the code snippet from your functions.php or deactivate the plugin. The Posts menu will reappear immediately. There is no permanent effect on your site.

Frequently Asked Questions

Will removing the Posts menu delete my posts?

No. The code only hides the menu item. Your posts remain in the database and are still accessible via direct URL or if you temporarily re-add the menu.

Can I remove the Posts menu for only some users?

Yes. Use the current_user_can() function to conditionally remove the menu based on user role or capability. See the example above.

What if I use a custom post type that replaces Posts?

If you have a custom post type (e.g., “Projects”), you can still remove the default Posts menu. The custom post type will have its own menu item, which will remain visible unless you also hide it.

Is it better to use a plugin instead of code?

For non-developers, a plugin like Admin Menu Editor is safer and easier. For developers, the code snippet is lightweight and has no performance impact. Both methods are valid.

Why does the Posts menu come back after I update my theme?

Because theme updates overwrite the functions.php file. To prevent this, add the code to a child theme or a site-specific plugin.

Can I hide the Posts menu from the admin bar at the top of the site?

Yes. The admin bar (the black bar on the front end) has a separate hook. Use admin_bar_menu to remove the “New Post” link or the entire Posts section.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →