• Resolved stuartcr

    (@stuartcr)


    Hi all,

    What i want:

    I want to be able to create posts with a custom url like this:

    mywebsite.com/plastic-surgery/before-and-after/nose-surgery/nose-1

    I have created a custom post type called “before and after”.

    I have also created a custom taxonomy call “surgery types” and added “nose-surgery”

    how do i get this to display

    mywebsite.com/plastic-surgery/before-and-after/nose-surgery/nose-1

    I assumed i would write this in the custom url rewrite

    mywebsite.com/plastic-surgery/before-and-after/%surgery-types%

    BUT this does not work.

    I also tried without the custom taxonomy

    mywebsite.com/plastic-surgery/before-and-after/%category%

    this also doesnt work

    HELP?

    Stay safe/ Stay Positive

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure how easy this is going to be, all in all.

    So we have this as a sample url:

    mywebsite.com/plastic-surgery/before-and-after/nose-surgery/nose-1
    

    You mention you have a “before and after” post type, so that makes the URL breakdown:

    mywebsite.com/plastic-surgery/POST-TYPE-SLUG/nose-surgery/nose-1
    

    You also have a “surgery type” taxonomy, with “nose surgery” as an example term. This gives us this:

    mywebsite.com/plastic-surgery/POST-TYPE-SLUG/TERM-SLUG/nose-1
    

    Since we’re dealing with content, I assume “nose-1” will be the post slug

    mywebsite.com/plastic-surgery/POST-TYPE-SLUG/TERM-SLUG/POST-TYPE-POST-SLUG
    

    What’s “plastic surgery” in this case? A page a site in a subfolder based multisite network? Just a folder on the server holding an install?

    Depending on the answer to that, WordPress could be interpreting the entire URL as a bunch of child pages for a “plastic-surgery” page.

    mywebsite.com/PARENT-PAGE/CHILD-PAGE/CHILD-PAGE/CHILD-PAGE
    

    Hard to say for sure without having an actual URL to visit and seeing what sort of query is being made.

    The URL structure, as I’m sure you can imagine, is actually pretty important to WordPress so that it knows what to query for. This is why you see things like post type and taxonomy slugs in the URLs. It is saying “look for a post with this slug from this post type” or “look for posts that have this term in this taxonomy” etc.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Any changes or new developments @stuartcr ?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom rewrite’ is closed to new replies.