Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?
share|improve this question

3 Answers 3

up vote 6 down vote accepted

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.

share|improve this answer
    
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. –  Average Joe May 15 '12 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 '12 at 21:40
    
good enough. thank you. –  Average Joe May 15 '12 at 21:41
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. –  goto10 May 15 '12 at 22:03

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 '';
}
share|improve this answer
    
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. –  Average Joe May 17 '12 at 6:54
    
You still get all the functionality built into posts but they can be called whatever you want. –  Chris_O May 17 '12 at 6:56

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

share|improve this answer
    
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 '13 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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