1

I've created taxonomy (schedule_day_taxonomy) for a specific custom post type (schedule).

add_action( 'init', 'schedule_day_tax_func' );
function schedule_day_tax_func() {
    register_taxonomy(
        'schedule_day_taxonomy',
        'schedule',
        array(
            'hierarchical' => true,
            'label' => 'Day',
            'query_var' => true,
        )
    );
}

Now the taxonomy DAY appears only in the custom post type schedule I've created `7 terms' from the admin panel.

Days

Now I want to remove Add New Category option permanently for all the users and admin.

How can I do that?

1

This check:

    <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?>

needs to be satisfied to display the "Add New Category" link.

You can set the capabilities for your schedule_day_taxonomy taxonomy, when you register it.

Example

Only users with the edit_schedule_day_taxonomy capability can edit the taxonomy:

add_action( 'init', 'schedule_day_tax_func' );
function schedule_day_tax_func() {
    register_taxonomy(
        'schedule_day_taxonomy',
        'post',
        array(
            'hierarchical' => true,
            'label' => 'Day',
            'query_var' => true,
            'capabilities' => array(
                'edit_terms' => 'edit_schedule_day_taxonomy',
            ),
        )
    );
}

Without this capability, users can't edit this taxonomy. If you need to edit it, you can remove this from the code above or assign it to your admin user.

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.