I managed to fix this.
Basically I changed the permastruct to this:
$wp_rewrite->add_permastruct('showroom', 'location/%state%/%city%/%showroom%', false);
I then grabbed state & city as two separate variables, replacing it in the permalink structure using these lines:
$permalink = str_replace('%state%', $state, $permalink);
$permalink = str_replace('%city%', $city, $permalink);
With $state
& $city
grabbed using get_post_meta
from the post.
Related Posts:
- How to use a specific custom field in a custom post type as slug
- Generate slug and meta data if meta field is empty
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- First custom field value (out of several) displayed twice after query
- Removed custom post type slug but not working for child pages
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Meta Query posts not showing on ending date of custom field
- Cannot save CPT meta box
- Cross reference custom post types
- Including taxonomy term before post type breaks top level pages
- Adding Page Templates to post but it ignored it
- Include related custom fields from one post type in another post type’s JSON feed
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- frontend image post uploader
- Is there any way to add a “custom field” to the CPT archive page?
- How to Output which matched meta_keys were found from custom_type_posts?
- Multiple Frontend Filters Using Advanced Custom Fields
- Custom Post Fields at the beginning of a Custom Permalink
- Can slugs from posts and custom post types conflict?
- Integrate Custom Post Type Events into Calendar
- Possible to filter custom post type with multiple meta data?
- Hierarchical custom fields
- How to get a custom field value of a custom post?
- Fields for different parts of a page
- Is it possible to activate customfield ‘text description’ upon activating the customfield ‘checkbox’?
- Facebook social publisher and custom post type fields [closed]
- Custom Post Type – Duplicate Page Slugs
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- Displaying and searching Custom Posts
- Importing Data from a Non-WordPress database, into WP
- custom comments form for custom post type
- Searching Custom Fields
- Show fields based on taxonomy selection in editor
- filter search custom field query
- Permalinks: custom structure for taxonomy – tags?
- How to let users choose where to search for posts?
- don’t publish custom post type post if a meta data field isn’t valid
- WebP Fallback for Inline Background Image in Style Attribute
- Query based on custom fields start and end date
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom fields for custom post type
- How can meta boxes be added to “unknown” custom posts?
- Custom “radio button meta box” not saving correctly
- Redirect to another page using contact form 7? [closed]
- It’s possible to hide body copy box for a custom post type?
- Can we create a custom post template for a specific page template
- Warning: Invalid argument supplied for foreach() [closed]
- Settings API – save multiple tabs at once
- Add additional field to custom post_type
- How to Get the title of a custom field?
- Remove permalink for custom post type
- Custom Post Meta from custom metaboxes is randomly being deleted
- Auto Slug Generation for Custom Post type
- Check if post with same meta value exists
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- How to make a posttype show under a page hierarchy (example.com/page/posttype/entry)?
- Custom Post Type archive-{post-type}.php not working
- Custom post type single page (single-{CPT-name}) 404 when slug includes hyphens
- Multiple single templates?
- Custom Field values not Showing in Edit Page of Custom Post Type
- How do you create %post_type%/%postname%/ permalink structure?
- How can I add a custom field to an existing custom post type?
- Add a custom meta box for client to order CPT posts how they want
- Custom posts type for individual pages?
- Custom post type’s extra fields – how to handle?
- custom post data – how to
- Slug for custom post type
- Send a conditional email notification when a custom field value changes in Post Type
- Enable Custom Fields For Custom Post Type When CPT Created Using Plugin
- Rename a slug label
- Create custom post with meta field with AJAX and the WordPress REST API
- Specifying meta field’s column type in Database using add_post_meta
- Slug Confusion Between Post and Custom Post types?
- How to find a specific post_type using its “rewrite slug”?
- How to get a custom type post data when it has a connection with another custom type post?
- Get Post Terms of Current Post (selected taxonomy term) – How to get only the taxonomy value and not “Array ( [0] => taxonomy term )” in the frontend?
- Add post meta programmatically to attachment
- WP Query ‘posts_per_page’
- Submitting Custom Post Types with custom fields from Front-end form
- Custom Post Type Metadata Not Saving
- How to create multiple editor?
- How to customize work area / admin area in a custom post type without plugins?
- Display Repeatable Meta Box Content
- create custom meta box with default value
- Different slug taxonomy for two different CPT
- ACF in wordpress
- Display post from a date range from custom field
- Editor / Add Media: Is it possible to only allow galleries?
- Creating custom post type with custom taxonomy and custom fields programatically
- How to add current custom taxonomy slug to body class
- Change Slug of a Custom Post Type
- Using page slug in wp_query
- How to display custom field value on page?
- post_per_page ignored in WP_Query
- List of users that clicked a ‘Join’ button at single post
- delete_post_meta() for whole CPT / multiple posts?
- Get Specific Template Part if Custom Field is Some Value
- How can Custom Post Type and a page have the same slug?