A have a post type for venues
which have the attributes title
, state
, and suburb
. Currently using the default WordPress permalinks I get the following format:
mysite.com/venue/{title}
However, I would like to have the full url be:
mysite.com/venue/{state}/{suburb}/{title}
This information is something that can be retrieved from the database, with permalinks off the url format for this would be:
mysite.com/?venue=title
I believe it’s also possible to pull it by ID some how…
My question is, how do I create a rewrite rule that pulls this information based on post_id
or title
to create a url of this format?
Is it even possible?
Sorry I took so long to write this up. Hope it’s still useful.
This is based off of a tutorial found here and some general playing around.
Key thing to notice is in the second function where I have the comment for your custom data. Replace the second argument of the
get_post_meta
function calls with the names of your respective custom meta data. After you insert the code, go to wp-admin>Settings>Permalinks and click save to refresh your rewrites and voila.Let me know if you need clarifying on anything.