Since I have less reputation I can’t comment, this is not answered with code but wanted to help, you may check this plugin: https://wordpress.org/plugins/redirect-404-error-page-to-homepage-or-custom-page/ or just take required code from the plugin ( I am not connected with that plugin anyway )
Related Posts:
- base directories / URL
- Custom Taxonomy leads to 404 page
- How to show taxonomy on front page
- All tag/category/custom taxonomy archives 404
- How to manage the links of a new taxonomy
- Why do my offline development site and online live site behave differently?
- Pages throwing 404 error on server load
- Taxonomy link not working (leads to 404 page)
- Attaching taxonomy data to post with wp_insert_post
- How to get taxonomy term of the current page and populate queries in the template
- tax_query in get_posts() not working?
- wp_set_object_terms() — prevent overwrite?
- Get_term_by only returns one item from array
- How to have “the most used tags” taxonomy always expanded?
- Get parent and first child taxonomy terms?
- Display the number of published posts for each custom taxonomy term?
- Get wordpress taxonomy archive and sort by year
- Missing term_id and term_taxonomy_id when adding a term using wp_insert_term() function
- What hooks/filters are there to alter selected terms on post save?
- Filter blog archive by category in URL
- Using a custom field value to redirect away from a 404 page
- tax_query: What to pass when I want to have all terms?
- Custom Roll/Custom Post Type – Can’t Select Categories
- Redirect feed to 404 page
- Redirect old permalinks with Month and name to Post name on new site
- Trying to list terms of a custom taxonomy using get_categories
- Add a term to an attachment submitted from front end
- Get and loop posts with all taxonomy terms
- Unable to delete a Category and Tag that share same slug
- what tables uses wp_get_post_terms
- Deny access to a path (give 403 or 404 response)
- List a current posts’ taxonomy terms in a widget in WordPress
- Custom taxonomy is crashing Gutenberg
- How to show the category filter that’s shown on the ‘All post’ pages on a custom post type page in the admin area?
- Should I be using custom post types for this or terms and taxonomies?
- How can i list the categories of a post type, the taxonomy
- Defining a custom 404 for non-WordPress parts of site
- Set post terms on post publish
- Issue with htaccess redirection in WP Multisite
- How to display terms from a custom taxonomy in a hierarchy AND with custom html markup?
- How can I find the taxonomy in edited_{taxonomy}?
- extend HierarchicalTermSelector function with custom renderTerms
- Searching in wordpress using wp_term_taxonomy table
- Built-In Postname Redirection vs Hard Redirects in relation to SEO and performance
- 404 redirect to previous category
- Pulling Data from CSV vs. pulling data from database
- “AND” relation in custom taxonomies
- Problem with Query on Taxonomy
- Comma separated tax terms, with “and” before last item [duplicate]
- How to add and display a taxonomy term image in any template? (Taxonomy Images)
- I used single quote to design HTML of my WordPress blog. Now site redirects to index.php everytime than page.php or single.php
- Taxonomy term page going to 404
- How to redirect a wrong search on my wordpress website to the error 404 page?
- Get Link to Feed On Term or Taxonomy
- Creating links to a page displaying posts from a particular category
- Custom taxonomy template list not working (404)
- Blogroll links sorted by category in a table
- Custom taxonomy template shows 404 Error
- How to relate a user object to taxonomy term?
- How to redirect non existent pages/posts in wordpress using htaccess
- Taxonomy vs Post Status
- Declaring arguments for taxonomy
- Taxonomy Checkbox Admin Panel
- Prevent certain subscribers from seeing specific taxonomies (changes frequently)
- Replacing a placeholder term with a session variable value in taxonomy filter
- child_of not working in wp_dropdown_categories
- How to display posts from two taxonomies?
- Using taxonomies to handle layout?
- Return single taxonomy term outside the loop
- WP Search using taxonomy terms
- How to embed the Taxonomy Admin screen in to a Tab of a Settings Page in a plugin
- Calling an Archive Page with specific Tag/Tax ID
- Assign Multiple Values from Post Fields to Taxonomy Terms
- how can send a parameter by click on gender-link to filter a post by gender and product taxo
- Taxonomy terms are not checked when edit custom post
- How best to add Author or Artist to product
- Order custom taxonomy hierarchy
- Including taxonomy in searches
- Different Sidebar for same Taxonomy
- I want to get term by term_name without taxonomy
- How Do I Register Two Taxonomies with one Parent of the Other?
- Custom taxonomy named ‘tag’ return 404 page
- Translation ready code format for taxonomy
- Create multidimensional array of taxonomies
- how to display taxonomy name in do shorcode php tag
- Can I have have terms with the same slug in the same taxonomy?
- How to customize taxonomy edit page
- Categorizing posts by location
- How to filter the terms to a special custom taxonomy?
- How can I create gallery of products and submit data for each product?
- Order taxonomy terms by the frequency of use in the last 30 days
- Why can’t I exclude a term ID from either get_terms or WP_Term_query?
- get_term_link doesn’t work
- What is the ‘selected’ parameter in wp_dropdown_categories() for?
- Taxonomy works in local XAMPP but doesn’t work live
- Append taxonomy url
- get_terms of specific parent (including the parent itself)
- Post pages are redirecting to the 404 page in wordpress
- Operator ‘AND’ in the get_posts() function’s tax_query terms not working
- Displaying custom tag cloud as list results in empty href tags