1

I plan on skipping the Posts post type once and for all. This is a brand new portal. It will have 100s of thousands of content in the form of articles, multimedia, and links. Instead of Posts, I will be using a custom post type called "Articles." Similarly, for my video, audio, and picture posts, I will be using another CPT called "Multimedia."

I'm doing this to bring a one standard across all actions that is anytime we post anything, that's a CPT. That helps me deal with urls, Admin UI, who has control over what, what taxonomies to show when, and all that.

Two questions:

  1. how do you get rid of the post menu on the admin ui?
  2. any issues of skipping the post type and not using it at all?

3 Answers 3

7

1. how do you get rid of the post menu on the admin ui?

Simple, just un-register the post post type. There isn't a default function to do this, but one of the core developers (Nacin) posted some sample code on a WP Trac ticket showing how it can be done:

if ( ! function_exists( 'unregister_post_type' ) ) :
function unregister_post_type( $post_type ) {
    global $wp_post_types;
    if ( isset( $wp_post_types[ $post_type ] ) ) {
        unset( $wp_post_types[ $post_type ] );
        return true;
    }
    return false;
}
endif;

2. any issues of skipping the post type and not using it at all?

Be forewarned that unregistering default post types is not recommended. Just because you can do something doesn't mean you should. My best recommendation would be to use the default posts as your articles in the first place.

Remember, posts and pages are registered just as any other CPT would be. So deregistering posts just to register articles is akin to reinventing the wheel.

3
  • How about removing the 'posts from the admin menu then. I don't mind keeping the 'posts' as a built-in post type ( even if I do not plan on using it ) . As long as it does not show up there, that's fine. But more importantly, please eloborate in your answer why you think it is not a good idea to remove the posts post type? What's the harm? Why do I have to live with the add post! - as opposed to add articles. If this had issues, why is Nacin showed the way then ? Thx. May 15, 2012 at 21:33
  • There's no real harm - just a bunch of extra coding on your end. The default loop/query for WordPress supports post as a post type. If you remove that to add article you're forced to specify it every ... single ... time you want to query articles. As I said in my last sentence, you're reinventing the wheel ...
    – EAMann
    May 15, 2012 at 21:40
  • 2
    It's also worth noting that you'll lose the built-in date-based archives as well as author archives. There are ways of re-inventing them for your CPT, but still. May 15, 2012 at 22:03
7

As another option you can keep the default post post_type and change the menu label and all the other labels associated with it.

add_action( 'init', 'c3m_change_post_object_label' );
function c3m_change_post_object_label() {
    global $wp_post_types;
    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'Articles';
    $labels->singular_name = 'Add New Article';
    $labels->add_new = 'Add Article';
    $labels->add_new_item = 'Add Article';
    $labels->edit_item = 'Edit Article';
    $labels->new_item = 'New Article';
    $labels->view_item = 'View Article';
    $labels->search_items = 'Search Articles';
    $labels->not_found = 'No Articles Found';
    $labels->not_found_in_trash = 'No Articles found in Trash';
}
add_action( 'admin_menu', 'c3m_change_post_menu_label' );
function c3m_change_post_menu_label() {
    global $menu;
    global $submenu;
    $menu[5][0] = 'Articles';
    $submenu['edit.php'][5][0] = 'Articles';
    $submenu['edit.php'][10][0] = 'Add Article';
    echo '';
}
2
  • I think this is a better way to go. This is going to miss the multimedia and external links post types being included in the search results but at least aricles(=posts) will be there. May 17, 2012 at 6:54
  • You still get all the functionality built into posts but they can be called whatever you want.
    – Chris_O
    May 17, 2012 at 6:56
0

i know this is kind of an old thread, but i just found this very small script on GitHub that is pretty damned handy for unregistering custom post types:

Unregisters a post type and removes the menu item

1
  • I can't actually get this to work. Complains that remove_menu_page() is undefined. Would really like to get rid of Posts for the same reason as the original poster.
    – GhostToast
    May 2, 2013 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.