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
- Custom Post Type Settings page, choose page to display archive
- Adding custom post type archives to a WordPress menu
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- Custom field values deleted when trashing custom post type
- Custom Post Type Archives by Date with Custom Permalink
- How to rewrite custom post type URL for multiple depths instead of one specific depth
- Use Custom Post Type as Custom Field
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Regex problem in an add_rewrite_rule
- Saving multiple Metabox contents
- archive-{$post_type}.php not loading. instead the default archive.php loads
- Interesting Custom Post Type Slug with Taxonomy and Custom Field
- Custom post type / custom fields
- Assign Taxonomy Based on Custom Field Value
- Assigning the same custom meta box to multiple post types
- How to remove slugs from multiple custom post types
- Custom taxonomy in URL showing 404
- Rewrite slug of custom post type to include post-id
- Displaying Page as Custom Post type landing Page
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- How do I associate a custom post type with another through a taxonomy or storing an ID in a custom field?
- Orderby CPT custom fields not working
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Rewrite Question Mark in Post Template to Make it Pretty URL
- Hierarchy and access control for Custom Post Types (CPT)
- How to get list of taxonomy slugs ordered parents>childs?
- Rewrite Endpoints and CPTs – How to use in a plugin
- Paginate_links in custom post type template
- Custom Post Meta from custom metaboxes is randomly being deleted
- Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters
- Custom Post Type posts, conflict with posts after add_rewrite_rule to top
- echo selected value from dropdown
- Get data from PHP to JavaScript to set position of each post on front page
- Page inside custom post type (url rewrite?)
- Get custom term meta problem on single post type
- Incorrect ordering of custom post type based on time
- How can I see a list of products that I have set to outofstock through a custom field check box?
- Custom Post Type URL Rewrite’s
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- CPT archive page – show one post from each taxonomy term
- Adding a location field to buddypress activity
- Rewrite URL for CPT to domain/post-name/post-id
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Custom permalink structure for custom post types including multiple taxonomy
- How can I assign multiple parents to CPT?
- How to convert Post Object Custom Field into Tags
- 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
- How can I register multiple custom post fields to json?
- Sql Update CPT from publish to draft and particular custom field
- Rewrite url for custom post type with specific url
- Custom post pagination not working
- WordPress loop add heading before first of type
- Rewrite Endpoint Url without ? before endpoint
- Rewriting archive page slug to be different than custom post type slug
- Custom Rewrite Tag Structure
- How do I add custom fields to posts without having to manually add everytime I post?
- How to display custom post type ordered by a custom field date
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- WP_Query and two custom fields returns no posts
- Parent cpt/child custom post type URL permalink relationship
- Is it good practice to search for custom posts based on custom field values?
- Repeatable Custom Field for Media Upload
- How to store datetime from custom meta box so that it can be sorted by
- Custom Post type easy way for editors
- Adding a custom field after post title (ex.Example Title [30 Second Read])
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Display ACF object field data using Elementor Custom Query