Skip Navigation

[Resolved] Wondering how to turn off the archive pages for custom taxonomies

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Author
Posts
#1828563

Hi there,

Just wondering if it's possible to turn off the archive pages for custom taxonomies?

Thanks,
Christine

#1829279

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can disable the taxonomy archive by adding the following code to your theme's functions.php file:

add_action('pre_get_posts', 'kill_taxonomy_archive');
function kill_taxonomy_archive($qry) {

    if (is_admin()) return;

    if (is_tax('tax-slug')){
        $qry->set_404();
    }
}

Where:
- Replace 'tax-slug' with your original taxonomy slug

More info:
=> hidden link
=> https://wordpress.stackexchange.com/questions/140351/how-to-completely-disable-a-taxonomy-archive-on-the-frontend

#1829825

Just wanted to confirm that this code will also disable the individual taxonomy pages as well?

Eg. If I have a taxonomy with the following slug 'career-department' and the category 'support-staff'. Will that code prevent both these pages from being created?

/career-department
/career-department/support-staff

??

Thanks

#1829845

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I do not see you can access the taxonomy archive with archive slug: /career-department

For the following case:
/career-department/support-staff

if you have added the code as given under:

add_action('pre_get_posts', 'kill_taxonomy_archive');
function kill_taxonomy_archive($qry) {
 
    if (is_admin()) return;
 
    if (is_tax('career-department')){
        $qry->set_404();
    }
}

It will display 404 page for all the category/terms belongs to taxonomy career-department.