Nested Custom Post Types??

Support MB Custom Post Type Nested Custom Post Types??Resolved

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #46586
    JordanJordan
    Participant

    I'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:

    CPT structure

    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?

    #46587
    JordanJordan
    Participant

    #46588
    JordanJordan
    Participant

    Embedding images here is a pain so here's the CPT URL STRUCTURE

    #46596
    PeterPeter
    Moderator

    Hello 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-taxonomy

    #46598
    JordanJordan
    Participant

    After 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-service

    The test service has relationships properly set, as well as the city, state and county.

    #46599
    JordanJordan
    Participant

    <script src="https://pastebin.com/embed_js/3WbxzWjS?theme=dark"></script>

    Pastebin PHP

    #46603
    PeterPeter
    Moderator

    Hello,

    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.

    #46604
    JordanJordan
    Participant

    I've submitted the form.

    #46624
    JordanJordan
    Participant

    I haven't heard anything from the team after submitting the form.

    #46627
    digisavvydigisavvy
    Participant

    hey 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.

    #46632
    JordanJordan
    Participant

    Hey 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?

    #46634
    digisavvydigisavvy
    Participant

    Tell 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.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.