0

I want to:

  • Control the name of the Posts post type, like I can with custom post types
  • Set an archive page for posts e.g. example.com/posts, like with custom post types
  • Control the archive slug, like I can for custom post types

But I can't. I can create a new post type and unregister_post_type('posts'). Wait for it... I can't. Or can I somehow? This ticket addresses just that but the function unregister_post_type doesn't exist yet, right?

What I can do is to hide Posts from the menu. But it's not removing them. I have to take two detours here. Wouldn't it be just great if the default post types could be controlled like custom post types? Anyone else feel the same?

There's probably a reason for all this that I'm just not aware of.

enter image description here

Thanks!

1

You can use the globals $menu, $submenu and $wp_post_types for renaming.

Code:

    function wpse124233_alter_builtin_post_menu_label() {
        global $menu;
        global $submenu;
        $menu[5][0] = __( 'YourName' );
        $submenu['edit.php'][5][0] = __( 'YourName' );
        $submenu['edit.php'][10][0] = __( 'Add YourName' );
        $submenu['edit.php'][16][0] = __( 'YourName Tags' );
    }
    add_action( 'admin_menu', 'wpse124233_alter_builtin_post_menu_label' );

    function wpse124233_alter_builtin_post_labels() {
        global $wp_post_types;
        $labels = &$wp_post_types['post']->labels;
        $labels->name = __( 'YourName' );
        $labels->singular_name = __( 'YourName' );
        $labels->add_new = __( 'Add YourName' );
        $labels->add_new_item = '__( Add YourName' );
        $labels->edit_item = __( 'Edit YourName' );
        $labels->new_item = __( 'YourName' );
        $labels->view_item = __( 'View YourName' );
        $labels->search_items = __( 'Search YourName' );
        $labels->not_found = __( 'No YourName found' );
        $labels->not_found_in_trash = __( 'No YourName found in Trash' );
    }
    add_action( 'init', 'wpse124233_alter_builtin_post_labels' );


Additionally you could use get_post_type_object() to alter the built in post types. Take a look at the answer to Modify built-in post type properties to get an insight in how to do it. But messing around with the built in post types isn't the best idea, unless you're absolutely sure you know what you're doing. Personally I avoid doing so and instead use custom post types for differing functionality I want to implement.

Beside that, sure sometimes it would be nice(r) to have more control over built in functionality, but most things are customizable, or can be added as extra functionality. The reason might just be to have an built in set of functionality, not only posts and pages, but everything else too, optimized to work with each other. Which makes wordpress pretty extensive and powerful after just installing it and having the defaults available.

There are some possibilities to have a cleaner, purer, essential start:

  1. WP Strip Naked

    • by @kaiser
    • Github
    • About:

      Strips down WP to it’s bare essentials. Removes everything that’s not needed to be in place if you use WP as a CMS. There are no options needed. The plugin works out of the box – just activate!

  2. Backpress

    • Homepage
    • Beware this isn't wordpress anymore
    • About:

      BackPress is a PHP library of core functionality for web applications. It grew out of the immensely popular WordPress project, and is also the core of the bbPress and GlotPress sister-projects.

  • 1
    @any_h: My pleasure! I should have mentioned, you can take a look at the WP Strip Naked code to find out about disabling, unsetting, removing all those things that are combined in it. For example the built in post type »post«. – Nicolai Nov 23 '13 at 17:45
0

So, turns out that removing built in post types is actually really easy *forehead slap*. Here's how:

// Remove Posts
add_action( 'init', 'remove_posts');
function remove_posts() {
   global $wp_post_types;
   unset( $wp_post_types['post'] );
}
// And it's menu item
function remove_menus(){
    remove_menu_page( 'edit.php' );
}
add_action( 'admin_menu', 'remove_menus' );

Further reading:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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