Like Bainternet said in comments, you’ll need to mess with add_query_var
as well as add_rewrite_rule
.
We usually do something similar to:
global $wp;
$wp->add_query_var( 'some_var' );
add_rewrite_rule( 'some/path/([^/]+)/?$', 'index.php?some_var=$matches[1]' );
See this WordPress Trac ticket, as well as documentation on add_query_var
and add_rewrite_rule
Related Posts:
- Rewrite custom post type url’s adding meta box values
- Custom post type yearly/ monthly archive permalinks
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Adding meta values to permalink
- Custom post type permalink structure with the category also acting as an archive
- How to create download links based on Custom Fields with Rewrite API
- Custom query variable – get wordpress to redirect to nice permalink url
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- Query var removed after rewrite
- CPT Archive with core Category
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- 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
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Custom post type archive with page as parent url
- Combine multiple CPT names to create valid permalinks
- Archive page for custom post type and custom taxonomy
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- Custom taxonomy terms as children of multiple custom post types
- How to change URL for custom post type archive?
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- add_rewrite_tag broke permalinks that doesn’t use that specific tag
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Meta_query by date for Events archive
- Show index and not the archive for “Dog Custom Post” with default slug
- Custom post type and custom taxonomy archive inaccessible
- Custom Taxonomy in Permalink from post type
- Custom archive URL as a subfolder of the custom post type slug
- How to work with URLs where sometimes a post or a subcategory is in the same part of the URL structure
- Remove date rewrite rule for custom post type archive page
- Rewrite taxonomy permalink appended to CPT archive url
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- Static Front Page not working for custom theme
- register_rest_field update_callback don’t work for $_FILES
- Query custom post type and custom field by URL parameters
- Where is get_post_meta value located?
- Display CPT taxonomies as an archive page
- How to convert Post Object Custom Field into Tags
- How do I query with multiple custom fields orderby in same column?
- PHP Warning with Custom Fields
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- I want to create a metabox under custom taxonomy
- Do not show child pages within a file page
- Custom Post Type not using correct page template
- Change CPT permalink to use the category
- meta query multiple values for the same key
- Problem with multi checkboxes value in metabox?
- How can I register multiple custom post fields to json?
- CPTUI rewrite disable when no post in CPTUI has been found
- add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working
- How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug
- Tell wordpress to show a single page instead of an archive page
- Display Custom Post Type Archive content with Shortcode
- Sort custom post archives by a meta value from a different custom post type?
- Permalink for custom post type pages not working
- Custom Post Type parent/child relationship rewrite rules for permalinks
- filter using custom fields
- Rewrite of Custom Post Type doesn’t work with dynamic data
- Show Post columns to specific users on condition
- Custom Post Type archive page listing a 404 or single post
- Displaying Custom Fields from Custom Post Types [closed]
- Add %post_id% to slug of custom post type and prevent the “unique slug” thing that WP does?
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Redirect Custom Post Type from Child Taxonomies
- Displaying posts inside table having issues
- Custom post types – meta_query: search lesson which starts sooner
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Sql Update CPT from publish to draft and particular custom field
- Custom post types & Pages hierarchy – Error 404
- Ordering Post by Meta Key (Not Working)
- Rewrite url for custom post type with specific url
- Post Filtered by Custom Field Value
- Customise Permalink Structure For Custom Post Types
- Adding a Section for Visitors
- Error when moving custom post type to bin
- Custom post type structure + permalink structure
- Automatic Set Category For A Custom Post Type
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- How to link custom field of two custom post types?
- How to use a custom post type as child of a particular post of another CPT?
- How to make “single post” permalink maintain it’s sub-page structure
- Building Link List for Custom Tax
- Custom taxonomy with custom post type archive page
- Custom Post Type canonical link / pagination redirecting to root
- How to replicate data storage and querying using WordPress. Custom posts/fields or Custom db tables?
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- Rewrite URL of Specific Post of Custom Type
- CPT – Custom Text fields point to new url permalinks
- Custom post pagination not working
- Autofill advanced custom field with user data
- Confused about where to store my data
- Using get_post_type with a custom URL format?
- Advanced search form with multiple custom fields
- filter rest api post by a acf filed
- Custom Post Type / Taxonomy / Term – what template to use to avoid 404-page?
- Unsure what page hierarchy to use with CPT UI to show on front end
- Query posts by multiple custom fields
- How to prepend text to custom field value A, but only if custom field value B matches a certain string?
- Enforce all custom posts have specific custom fields