I solved by eliminating the following portion of code: I don’t remember why I had to code it, it apparently solved an issue, even if I don’t remember what issue.
The portion is the following:
add_action('pre_get_posts', function ($query) {
if (!is_admin() && $query->is_main_query() && empty($query->query_vars['suppress_filters'])) {
if (is_archive()) {
if (is_category()) {
$query->set('post_type', ['post', 'docs']);
} else {
if (!is_tag()) {
$query->set('post_type', 'docs');
} else {
$query->set('post_type', 'post');
}
}
}
}
});
Maybe a newer version of WordPress had compatibility issues with this code.
Related Posts:
- Getting hierarchical custom post type permalinks to work just like pages
- Custom post type 404s with rewriting even after resetting permalinks
- 404 on child page when parent page slug is identical to custom post type
- Hierachical Custom post types permalinks not working
- Remove Slug from Custom Post Type results in 404
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- custom post type and custom taxonomy url conflict
- Bizarre Permalinks Issue: 404 Errors Everywhere
- Custom taxonomy in URL showing 404
- Help with Elementor Pagination CPT archive 404 problem
- Using taxonomy term in CPT permalink – Pages 404’s
- Parent Page and Breadcrumb URL’s for Custom Post Types Not Working
- Custom post type archive pagination 404
- Custom post type permalink tag 404
- Hierarchical permalinks for custom post type and taxonomy
- 404 in custom post type feed with mistake permalink
- How to solve this custom post type goes to 404 page?
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- One Custom post type 404’s others don’t
- Custom post type permalink returns 404 when set to private
- Custom post type slug 404
- How to filter a custom post type by custom taxonomy without 404
- Post type Permalink
- Permalink Trouble with custom post types
- Permalinks not working (404) for the ‘item’ post type
- Safe to throw 404 error in request filter?
- Custom Post Type Child Won’t Come Through With Pretty Permalinks
- Custom post shows 404 after theme change
- How can I get custom post types to recognize pretty permalink variables?
- Enabling hierarchical in a Custom Post Type gives error 404
- Standard Page Child of CPT Not Found (404)
- Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks
- 404 Error On Custom Taxonomy Pages 2, 3, etc
- Permalink Structure for Multiple Post Type Archives by Taxonomy
- Taxonomy, Terms, and Template Files
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Adding meta values to permalink
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- Can you have two CPTs with the same permalink structure?
- Custom taxonomy & post slug permalink
- Removing CPT slug from URL results in 404 error for archive page
- how to use two permalinks for one custom post type
- Custom Taxonomy List links being re-written
- Custom Permalink Tag breaks Pagination
- Create second custom 404 page for selected post type
- Custom post type hierarchical permalinks not behaving as expected for parent/child pages
- Custom post type and taxonomy permalinks – Structure
- Custom Post Type and Custom Taxonomy Permalinks
- Change Permalink Structure for Tag.php template
- Remove post type slug of all post types from permalinks
- Add archive slug to default post post type
- Custom Post type and permalink settings
- Wrong request query on cpt and tax
- add category name to permalinks on product page /category-name/product-name
- WordPress add_permastruct unwanted matches
- Permalink for a custom post type isn’t working and I don’t know why
- Add custom post type settings to wordress default posts
- Assign same parrent Page to pages AND custom post types
- Custom taxonomy returns 404
- Removing Custom Permalink Structure for Custom Post Type
- Flush Rewrite Rules when new site is created on network
- Pretty URLs and custom post types
- Top Level pages in wordpress giving 404, but child pages working fine
- Lost of query parameter when using permalink
- make permalink go to a custom single.php file
- Post URL based on Custom Post Types variables
- Dynamic CPT permalink structure based on ACF field value
- Custom permalink not working and showing 404 page not error
- get the permalink never return with empty value
- Custom post type categories gives 404 error
- Redirect User From Registration Page To CPT (profile page) with custom url
- Direct form to a custom page template
- Custom Post Types,Permalink and Heirarchy
- Permalinks for single-[custom-post-types] not working
- Custom post type permalink structure to include the taxonomy
- Custom Post Type permalink doesn’t match post permalink
- custom posts permalinks url rewriting
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Can’t Export Custom Post Types With Export Tool In A Custom Theme
- How to enable to change Permalinks for Individual Custom Post Type
- Permalink for specific post type
- Show date as permalink for custom post type instead of post name
- Permalink for custom post type pages not working
- Change permalink incrementor into pseudo-subdirectory
- CPT – Custom Text fields point to new url permalinks
- Change custom post type permalink according to category
- pre_get_posts gives 404 error on Custom Post
- WP gives 404 error for custom post type with GET variable
- Metabox messes up permalink
- Create custom YouTube-like permalinks for multiple custom post types
- What am I doing wrong with my taxonomy?
- Cannot use pages created on WP
- Is it possible to have public posts in a non-public custom post type?
- Custom post type child page 404
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- Custom Post Type Permalink
- WordPress Custom Permalink Structure with Custom Post Type and Taxonomies
- Can’t preview custom post – Redirected to home page
- Problem with Custom Post Types, Taxonomy, permalink, Archive
- PHP Button Custom link [closed]