How to completely disable a taxonomy archive on the frontend?

s_ha_dum’s answer didn’t work for me, but this did:

/**
 * Completely disable term archives for this taxonomy.
 * @param  string $taxonomy WordPress taxnomy name
 */
function kill_taxonomy_archive($taxonomy){

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

            if (is_admin()) return;

            if (is_tax($taxonomy)){
                $qry->set_404();
            }

        }

    );

}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)