Ok, the solution here turned out to be setting the correct priority on the add_action
hook. Since we’re all hooking into init
to register our post types per the Codex, the priority will determine which register_post_type
function gets called first and, by extension, the order of the generated rewrite rules.
So, I needed my “gemstone” rewrite rules to be checked before the “product” rewrite rules, so if they match, the product rules won’t even be checked. It’s a bit annoying that I had to use a negative value for the priority argument to achieve this because WooCommerce uses a priority of 0 for their register post type action, but that’s a minor issue.
I still don’t know how best to make the attachment pages work (the bonus question from above), but that is probably best left to the core WooCommerce team.
Related Posts:
- Mixing custom post type and taxonomy rewrite structures?
- How to rewrite URI of custom post type?
- Rewriting a custom-post-type permalink with taxonomy term?
- Custom rewrite rules for archive page and single post
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- How to remove slug from hierarchical custom types in 3.5.2
- Custom post types – Use post_id in permalink structure
- Custom post type permalink: only use %post_id% and remove %postname%
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Rewrite custom post type rss feed links
- Using /%postname% for a custom post type
- Changing the URL Structure of a Paginated Custom Post
- Adding meta values to permalink
- rewrite get parameter with custom post type
- Custom Posttype Inheritance (and url structure)
- Permalinks so that one custom post type appears to be a child of another, not working
- Create permalink structure for one taxonomy archive per custom post type
- Slug for custom post type archive
- Custom permalinks
- Custom post type permalink changing itself every other change
- Remove unwanted part of permalink custom structure from CPT url?
- Custom post type’s get_permalink returns wrong url
- Prepend meta_value to permalink of post
- Custom Permalinks for Custom Post Types and Taxonomies
- Removing parent slug from URL on custom post type
- Permalinks for CPT breaks permalinks to pages
- Including two taxonomies in a permalink structure
- WP Rewrite Rules – Custom post type & taxonomy
- URL rewrite and navigation structure for wordpress custom post type
- Changing a custom post type “has_archive” after registered
- Remove base slug in CPT & CT, use CT in permalink
- Custom post type category, taxonomy and URL rewrite problem
- Permalink Structure problem with cpt and custom taxonomy
- how to use two permalinks for one custom post type
- Rewrite on custom post type permalink not working?
- Custom Post Type slug same as page name causing a conflict
- Custom Permalink Tag breaks Pagination
- Custom Permalink for Taxonimie and Custom Post Type
- Permalinks for Taxonomy and Custom Post Type
- Share parent path between Custom Post Types and Pages?
- multiple url slug for single custom post type
- Custom Post Type and Custom Taxonomy Permalinks
- Change URL of posts and also Custom Post Type
- remove permalink “front part” for custom post type
- Permalink Structure CPT With Custom Taxonomy Fails
- Change Permalink Structure for Tag.php template
- Making a custom help center page
- Add archive slug to default post post type
- Custom Post type and permalink settings
- Rewrite rules for custom posts types
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- 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?
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- WordPress custom post type permalink rewrite shows page not found
- Using taxonomy term in CPT permalink – Pages 404’s
- How to add rewrite rule to custom post type with parent in url with cpt ui?
- Custom post type as home page with custom url
- Customize Custom Post Type URL
- URL rewrite add author as base
- Custom Permalink to remove category word , keeping posts permalink with date?
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- CPT’s with landing page instead of archive – Url Rewrite?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Pretty URLs and custom post types
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Lost of query parameter when using permalink
- Custom permalink with child taxonomy terms
- Permalink misbehaving in Custom Post Types
- Best way to specify “article type” in URL
- How to have permalink like domain.com/term/postname?
- Set parent for custom post type archive rewrite url
- Route subpage to Custom Post Type
- Custom Post Type Advanced Slug
- Dynamic CPT permalink structure based on ACF field value
- Post type Permalink
- WordPress custom permalink and archive link for custom post type
- Custom Post Type nest under a normal WordPress Page
- custom posts permalinks url rewriting
- Use a different URL path / permalink for CPT
- Adding /blog in front of single posts (only)
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- 404 error rewrite permalinks
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- WordPress custom post type rewrite rule matches all pages returning 404
- Custom post type with parent page? Possible?
- Customizing the custom post type permalink
- URL Rewrite Adjustment for Custom Post Type causes template to revert to index.php
- Custom Post Type – Rewrite slug [duplicate]
- How can you preserve URLs when moving posts to a custom post type?
- Custom post type permalink structure
- Custom post type Premalinks main page and details page
- What is the best way to relate different custom post types?
- Allow child pages with the same base as the CPT slug