You can filter any type of template to override the template hierarchy. In this case the filter is 404_template
.
We’ll check if the location
query var is set, meaning the URL matched the pattern of a location
request, but the result was a 404. In that case, we’ll load the 404-taxonomy-location.php
template.
function wpd_custom_tax_404( $templates ){
if( '' !== get_query_var( 'location' ) ){
$templates = locate_template( '404-taxonomy-location.php', false );
}
return $templates;
}
add_filter( '404_template', 'wpd_custom_tax_404' );
This code should go in your (child) theme’s functions.php
file.
Related Posts:
- Pagination throws 404 error on custom taxonomy archive pages
- Pagination throws 404
- Custom Taxonomy archive returns 404
- Custom Taxonomy 404
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- custom post type and custom taxonomy url conflict
- Custom post type and taxonomy permalinks – Structure
- Custom taxonomy in URL showing 404
- Custom Post Type / Two level deep taxonomy (cat. and subcat.) uri problem (error 404)
- Wrong request query on cpt and tax
- Custom post URL 404 error
- Custom post type permalink tag 404
- Custom post type / taxonomy rewrite archive page 2 gives 404
- Hierarchical permalinks for custom post type and taxonomy
- Top Level pages in wordpress giving 404, but child pages working fine
- Custom Post Archive is not working
- Custom post type pagination 404
- How to solve this custom post type goes to 404 page?
- Which Template Page Should I Use?
- Custom taxonomy page returns 404
- Custom taxonomy template list not working (404)
- How to filter a custom post type by custom taxonomy without 404
- Taxonomy template page not working
- Custom post type categories gives 404 error
- Safe to throw 404 error in request filter?
- either single-{custom}.php 404’s OR /taxonomy/ 404’s – custom post type and taxonomy permalinks
- Archive page of CPT’s custom Taxonomy
- Custom taxonomy returns 404 even with saving permalinks
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- Making permalink for custom post type/custom taxonomy. Stuck with 404 in the single post
- 404 error next-page [2] PageNavi custom type taxonomy
- What am I doing wrong with my taxonomy?
- Custom post type archive page not showing on archive-posttype.php
- Multiple archives for cpt, taxonomies, terms
- How to assign custom post template to its custom taxonomy terms
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- Archive templates based on taxonomies
- Archive custom template from search
- 404 Error On Custom Taxonomy Pages 2, 3, etc
- Get The Post Type A Taxonomy Is Attached To
- Shouldn’t this be easy?! Custom post type/custom taxonomy permalink
- Custom Post Type Settings page, choose page to display archive
- Custom Post type & Taxonomy URL structure
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- How can I list all the categories under a Custom Post Type (taxonomy)?
- Two Custom Post Types, Share Two Taxonomies
- Querying Posts by Taxonomy From Alternate Network Site
- How to remove CPT comment feed from head?
- Permalinks when filtering multiple custom post types by single taxonomy
- Filter custom post type archive page with custom taxonomies (categories) with AJAX
- How-to leverage WordPress for creating Extended Social Profiles
- WordPress Genesis custom taxonomy archive shows 3 repeats of each post
- Custom Post Type Draft Preview Goes to 404
- Deleting Custom Taxonomy Term only increments tag_ID
- Best way to save horoscope data
- getting all values of a custom taxonomy if there is no post
- How to duplicate entire custom post type
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- How to display Custom Taxonomy under Custom Admin Menu?
- Is it possible to use have_posts function to list custom post type posts inside a category?
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- How to get list of taxonomy slugs ordered parents>childs?
- Custom taxonomy and post type with same slug
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- page not found for single-type.php file
- Template for custom post type when taxonomy is in the URL
- I am trying to get cutom post cout by month of current taxonmy term
- Query custom post types & Taxonomies and list them in a table on a page
- How to query custom post type by two terms?
- Get the link of the first post of a custom taxonomy in a custom taxonomy list
- add custom tags for custom post type in wordpress
- Custom Post Type URL Rewrite’s
- Auto Generate Post Title from 2 Custom Fields
- Custom front-end form for adding post – Category problem
- i want to send email to user when the custom taxonomy is changed
- Issues with static pages redirecting towards home.php
- Custom post type template – add banner under heading
- Get dropdown child categories from parent category of custom post type
- Store a value in global scope after init hook is fired
- How do you create pillar content pages?
- Custom post type single page returning 404 error when sharing archive url with custom taxonomy
- Grid slider with custom post type (how to filter with taxonomies?)
- Order posts by meta value hiding posts instead of re-ordering
- Set different posts_per_page for custom post type/taxonomy
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Facing some Issues on Two Parts Custom Post Type Taxonomy Names
- Change the url of a custom post type to include taxonomy
- Creating adminable dynamic filtering on custom post type
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- WP_Query for CPT with filter by another WP_Query
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- Query Posts with Custom Taxonomy from a Custom Post Type
- How to show a custom taxonomy using a custom template
- Get Registered Custom Post Type to get All Custom Taxonomies
- Parent cpt/child custom post type URL permalink relationship
- How to make a single Menu Item call another Mega Menu for Custom Post Types and Custom Taxonomies?
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT