Milo’s comment got me there:
add_rewrite_rule(
"^{$slug}/",
"index.php?location={$slug}", //changed query var to location
'top'
);
Related Posts:
- Resolve a custom post type name vs. page permalink conflict (same slug)
- How to enqueue scripts on custom post add/edit pages?
- Custom post type yearly/ monthly archive permalinks
- WordPress Custom Post Type is Matching on Partial Slug
- Custom routes for custom post type?
- How do I redirect all 404 errors of a specific post type to another URL?
- how do i create a specific handler for a url?
- Custom Post Types Not acknowledged for date.php template
- Calculate Repeater Meta Box Input Field Values and Display Total
- How to localize value of posts
- Bulk 301 redirect for custom post type
- How to create a repeatable / reusable divs in the metabox?
- Custom Scripts per page or Custom Post Type
- How do you use JavaScript to detect the homepage
- How to redirect all pages of a custom post type [duplicate]
- Redirect to post with only post ID in the URL vs post_type/post ID
- wp is not defined error using wp.media to create a custom image uploader
- WordPress Rest API only returns content when posttype has editor capability
- Custom post type routing with hierarchy
- Child page in custom post throws 404 page not found
- Multiple templates for a custom post type
- How to redirect wp-admin/index.php to a custom post type?
- How to set up htaccess to redirect a particular post type or subdirectory to HTTPS?
- Redirecting when changing custom post type slugs?
- Custom Post Type without an archive page
- Delete link on single-custom.php with redirection
- Redirect page to first post in custom post type
- Custom Taxonomy Permalinks Redirection
- Create/Edit posts and auto-redirect back to listing page
- Very simple wordpress block to display posts from an api call
- How to get the parent of a non-hierarchical custom post type being edited in Gutenberg
- Custom post type redirected to homepage – how to debug
- Storing posts from query and accessing later via AJAX call
- Push metadata in array
- redirecting improperly after updating custom taxonomy term when referring from CPT edit page
- Child post with numeric only slug keeps redirecting to parent
- Plugin – Combine Meta Box Input Fields into single saveble record
- JS innerhtml changing style when using AJAX
- Redirect 404 page with ID in slug to associated page with same ID in slug
- redirect automatic page that serves custom posttype content
- Side effects of Script and Iframe in post
- Dynamic Custom Fields
- Multiple Frontend Filters Using Advanced Custom Fields
- Can slugs from posts and custom post types conflict?
- Some posts from custom post type to subdomains
- Extracting Address from Custom Post via Javascript for Google Maps API
- Changed permalink structure of CPT – should I redirect?
- Combine multiple getEntityRecords calls
- Custom Post Type Slick Slider “$ is not a function”
- Custom URL redirect in WP
- Using wp_localize_script to get data from cpt and pass it to maplace-js locations
- Custom post type as child of page
- Redirect to archive is single post has a certain term assigned to it?
- Redirect to first child on Custom Post Type (without template)
- Create short URL with auto 301 redirect
- Get data from PHP to JavaScript to set position of each post on front page
- Check if user has custom post published redirection on WordPress
- Why is wp api returning old acf values?
- Custom Post Type archive redirects to home
- rewriterule not working
- Loading multiple post content in FancyBox
- Weird issue where form field loses focus to previous form field even with JS disabled
- WordPress/Javascript form not working on custom post type single posts
- Custom taxonomy permalink without term, redirection to CPT slug
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- redirect after submiting post for review
- How to implement very unusual wordpress routing structure?
- How can I put content before my custom post type default pages?
- How best to structure multiple CPTs and tax within a ‘resources’ section
- Redirect Existing Post to CPT
- Faking “Same Slug Root, Multiple Custom Post Types” with Redirects?
- Issues with static pages redirecting towards home.php
- URL issue retrieving Custom Post Types using Backbone JS API
- Randomizing WordPress Custom Post Type Sorting Through Them Without Page Refresh
- How can I use javascript in specific posts without relying on a plugin?
- How to use posts as tabs in a custom page?
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_get_nav_menu_items doesn’t return custom post type item
- Hide the update button from edit view in wordpress custom post type
- WordPress custom post type post item data – show/fetch only on click with Javascript dynamically?
- localize_script or rest api
- dynamic vue widget inside custom post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Custom Function to redirect singular post if specific meta field is empty
- Custom Post Type canonical link / pagination redirecting to root
- Add specific route for Custom Post Type (add/edit…)
- How to redirect custom post type posts to one url with htaccess?
- How to override post-new.php with custom template
- Custom 404 redirect for a luddite
- How to make sure, that only the selected post is changing?
- Redirect users in first login to a dynamic link
- Group based routing and administration
- How to develop custom URL redirection
- Redirect Custom Post Type after user submits update
- Redirection error after posting a comment on a custom type post
- Redirect preview single post link to a page
- Redirect permalinks after creating custom post types
- URL Redirection From Custom Type to Posts
- Loops running into each other
- Custom Post Type slug has the same Redirection entry