2

I'm developing a website with 3 different post types, and 4 different taxonomies to save the posts under.

The default post type and categories are unused in this template, and since many of authors are not very familiar with WordPress and we can't always control them, i wish to delete, change or at least hide the categories and default post from them, so they have to post it under a custom type.

For example, someone creates a new post under 'Breaking news' type, and assigns it to News Taxonomy, this post won't be categorized under any category (Uncategorized).

If he publishes this as a normal post type,it won't be shown anywhere in the website.

Is it possible to work around this?

  • Do you want to remove default post and category from admin area but not tags? – Vinod Dalvi Apr 20 '17 at 11:44
  • @VinodDalvi Yes that's what i want to do. I don't want writers to be able to create default post, or assign it to any category. – Jack Johansson Apr 20 '17 at 22:37
4

Yes this is possible with a very simple solution. Add this code snippet to your theme's funtion.php

add_action('admin_menu','remove_default_post_type');

function remove_default_post_type() {
    remove_menu_page('edit.php');
}

More info: https://www.techjunkie.com/remove-default-post-type-from-admin-menu-wordpress/ or https://codex.wordpress.org/Function_Reference/remove_menu_page

2

You can delete the default post type and category menu using below code.

add_action('admin_menu','remove_post_cat_menu');

function remove_post_cat_menu() {
    remove_submenu_page( 'edit.php', 'post-new.php' );
    remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=category' ); // Removes default category menu
}
  • Thanks, but this is already mentioned in the first answer. – Jack Johansson Apr 21 '17 at 9:48
  • The code don not remove whole default post like first answer but just add new and categories menu. Please advise if you want to achieve anything else. – Vinod Dalvi Apr 21 '17 at 9:53
1

Based on @Thijs answer, i managed to do this in 3 parts:

First, by removing the edit posts menu from the admin menu.

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

Then, by removing the new-post button from admin bar, and changing the default link.

add_action('admin_menu','remove_default_post_type');
function remove_default_post_type() {
    remove_menu_page('edit.php');
    $default_link = $wp_admin_bar->get_node('new-content');
    $default_link->href = '#';
    $wp_admin_bar->add_node($default_link);
}

Now, it's time to completely wipe categories from custom post types, but only assigning tags to taxonomies, while creating custom taxonomies.

'taxonomies' => array('post_tag' )

This will remove any trace of default post type and categories. Since the tag is assigned to taxonomies, we can still access tags from custom post type's menu. However the direct link will still be accessible, which can easily be blocked or redirected using user roles hook.

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.