Nested Custom Post Types??
Support › MB Custom Post Type › Nested Custom Post Types??Resolved
- This topic has 11 replies, 3 voices, and was last updated 6 months, 1 week ago by
digisavvy.
-
AuthorPosts
-
October 2, 2024 at 12:16 AM #46586
Jordan
ParticipantI'm having trouble using a previous created custom post type in the slug of the next custom post type. I know you can make a custom slug for a CPT, but you can't use the dynamic data from another CPT in the slug, like a State abbreviation. Example:
So the custom post types would be:
- Locations
- Services
or maybe I need locations, services, states, counties, cities.
Under Locations the slug would show the State abbreviation, the County, the City (/locations/state/county/city)
Under Services the slug would be /services/service - unless it's related to a location, then it would append the end of the location URL with /service/ so /locations/state/county/city/service.
Very standard URL structure for SEO, I hope this is making sense.
How do I achieve this in MetaBox?
October 2, 2024 at 12:18 AM #46587Jordan
ParticipantOctober 2, 2024 at 12:19 AM #46588Jordan
ParticipantEmbedding images here is a pain so here's the CPT URL STRUCTURE
October 2, 2024 at 10:21 PM #46596Peter
ModeratorHello Jordan,
MB Custom Post Types plugin helps you to create the CPT with UI and standard features of WordPress (https://developer.wordpress.org/reference/functions/register_post_type/), it doesn't support an option to have a dynamic slug for CPT and taxonomy.
You need to create some custom code to rewrite the CPT slug dynamically. Here are some examples:
https://stackoverflow.com/questions/51217355/custom-permalink-with-dynamic-rewrite-tags-on-a-wordpress-custom-post-type
https://stackoverflow.com/questions/59482836/create-a-dynamic-rewrite-rule-for-custom-taxonomyOctober 3, 2024 at 3:32 AM #46598Jordan
ParticipantAfter implementing this solution with the following code, the URLs are still not being rewritten.
<iframe src="https://pastebin.com/embed_iframe/3WbxzWjS" style="border:none;width:100%"></iframe>
The relationships are properly set in MetaBox:
state-to-county
county-to-city
city-to-serviceThe test service has relationships properly set, as well as the city, state and county.
October 3, 2024 at 3:32 AM #46599Jordan
Participant<script src="https://pastebin.com/embed_js/3WbxzWjS?theme=dark"></script>
October 3, 2024 at 11:04 PM #46603Peter
ModeratorHello,
Supporting the custom code is beyond our scope, please read more about support policy here https://support.metabox.io/topic/support-policy/
If you are not able to complete the task, we offer a customization service, please contact us by submitting this form https://metabox.io/contact/
for more details.October 3, 2024 at 11:35 PM #46604Jordan
ParticipantI've submitted the form.
October 8, 2024 at 5:03 AM #46624Jordan
ParticipantI haven't heard anything from the team after submitting the form.
October 8, 2024 at 10:16 PM #46627digisavvy
Participanthey Jordan!
I'm not sure if this will be a helpful suggestion, but I'd suggest picking up Permalink Manager Pro. I've had to use it for a few non-standard URL structures on client projects. I realize that might seem like a lazy answer but perhaps it's the one that gets you moving.October 9, 2024 at 12:14 AM #46632Jordan
ParticipantHey thank you for the recommendation! Another plugin though 😅 I wish they would just include CPT and rewrites in core! Have you had any issues with SEO or security using this plugin?
October 9, 2024 at 1:41 AM #46634digisavvy
ParticipantTell me about it, and PLEASE INCLUDE BETTER PERMALINK REWRITE SOLUTIONS IN CORE. I DON'T NEED FULL SITE EDITING.
I hear you on "yet another plugin" but it's light weight and honestly it's pretty lightweight ymmv. I haven't seen a huge impact +/- using this plugin. Including meta infos programmatically is pretty easy if it's not supported directly by your SEO plugin/theme or whatever.
-
AuthorPosts
- You must be logged in to reply to this topic.