The answer I’ve come up with on my own I know is a really bad idea. But it works and I have to have a working solution. (Doesn’t mean I can’t fix the problem later…)
add_filter('rewrite_rules_array', 'terminate_with_prejudice');
function terminate_with_prejudice($rules) {
// if we don't remove this we'll never see our custom rule.
unset($rules['(.+?)/?$']);
$rules = array_merge(array(
'distributors/?$' => 'index.php?show=all&post_type=distributor',
'((?!distributor)([^/]*?))/?$' => 'index.php?category_name=$matches[1]',
), $rules);
return $rules;
}
What this does is set the default rule to match against something that isn’t “distributor” and has one section prior to the slash.
I just hope no other plugins/themes do this!
Edit:
This breaks the ability to view a page. Great.
I could really use some help on this, folks.
Related Posts:
- Mixing custom post type and taxonomy rewrite structures?
- How to rewrite URI of custom post type?
- How to remove slug from hierarchical custom types in 3.5.2
- Custom post types – Use post_id in permalink structure
- Custom Post Type and Taxonomy URL rewrite
- Custom post type permalink: only use %post_id% and remove %postname%
- Rewrite custom post type rss feed links
- Is it possible to change the URL of custom post types to hide the post type slug?
- Archive page with multiple taxonomies rewrite
- rewrite get parameter with custom post type
- Taxonomy page returns 404 page not found
- Remove unwanted part of permalink custom structure from CPT url?
- How to have a custom URL structure for a custom post type?
- Display CPT taxonomies as an archive page
- Including two taxonomies in a permalink structure
- WP Rewrite Rules – Custom post type & taxonomy
- Changing a custom post type “has_archive” after registered
- URL Design for Sub-Posts?
- Remove base slug in CPT & CT, use CT in permalink
- How do I list terms of a custom taxonomy at i.e. domain.com/brands/
- Permalink Structure problem with cpt and custom taxonomy
- Custom Taxonomy 404
- Custom Post Type rewrite redirects to homepage
- Custom Post Type slug same as page name causing a conflict
- single-{post_type}.php is not loaded despite flushing rules
- Adding paged query to custom URL rewrite
- Custom Post Type rewrite rules not working, how to alter the rewrite order?
- Custom Permalink for Taxonimie and Custom Post Type
- Rewrite Custom Post Type URL slug
- Rewrite numeric ID parameter for hierarchical custom post type
- Customising rewrite rules for CPT single post URL to work as paged URL
- Remove custom post type slug not working for child pages
- Custom WP TItle from custom template with dynamic URL structure
- Rewrite rules for custom post type slug
- In WordPress how do you create a custom post type with the author’s name in the slug?
- Change URL of posts and also Custom Post Type
- Custom Post Type rewrite
- How can I display an archive of only one category of my custom post type?
- Permalink Structure CPT With Custom Taxonomy Fails
- Conditionally custom post type url rewrite
- Making a custom help center page
- Remove url rewrites for registered taxonomies
- Get Taxonomy Term Title by it’s URL
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- WordPress custom post type permalink rewrite shows page not found
- Using taxonomy term in CPT permalink – Pages 404’s
- Customize Custom Post Type URL
- Programmatically rewriting slug through functions.php but returns 404
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Why isn’t my custom post type archive URL translating?
- Custom Post Type and Category Base Rewrite Issue
- Rewrite URL of Custom Post Type for Jobs
- Post Type rewrite rule to point to custom Page/template
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Specific routing for CPT
- Lost of query parameter when using permalink
- Custom permalink with child taxonomy terms
- Custom post type archive with page as parent url
- Pagination custom post type not working with rewrite slug
- Custom Rewrite Rule for Custom Post Type with URL Param
- WordPress custom slug rewrite
- WordPress Custom Post Type – Rewrite Query
- After creating Custom post type by user delete old one
- Set parent for custom post type archive rewrite url
- Dynamic CPT permalink structure based on ACF field value
- URL Rewrite – Page Archive
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- custom post archive URL is wrong
- Rewrite rules for custom post type
- Custom taxonomy and post type rewrite rules
- WordPress is ignoring my post rewrite rule
- Remove cpt slug from url and use custom taxonomy instead breaks all other cpt
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- multiple URLS for the same page
- Duplicate content problems after adding an archive page to the article’s post type
- How to properly set the rewrite rules for this case?
- How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug
- Redirect Custom Post Type from Child Taxonomies
- Custom post type structure + permalink structure
- Rewrite URL of Specific Post of Custom Type
- Using get_post_type with a custom URL format?
- Custom post type rewrite and wp_pagenavi interfering with each other
- Show index and not the archive for “Dog Custom Post” with default slug
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- Paging not working for hierarchical custom post type
- Custom post type with parent page? Possible?
- redirect old post type url to new structure url
- Custom Post Type URL Rewriting
- Archive page for a custom post type using WPML
- Why is a custom post type’s URL “/?cposts=name-of-the-post” but default post’s URL is “/?p=ID”?
- Customize category URL
- Custom Post Type Rewrite Rule
- rewrite rules add a folder in the path
- How can you preserve URLs when moving posts to a custom post type?
- Custom Post Type Base URL
- Custom Taxonomy in Permalink from post type
- Custom Post Type and single-posttype template
- How can i change url structure of cpt like this?
- Menu Structure and URL structure, with Pages and Post-Type-Posts