I have a custom post type and two custom taxonomies associated with it. One is locations and the other is activities. How can I form the permalinks in the following format?
Therefore the first one would be the location taxonomy and second would be the activity taxonomy?
I recently talked about this at a couple of WordCamps. Here’s my talk from WC Portland, and the slides, source code, etc. Check out Recipe #2 specifically.
First off, you should probably have a static prefix to start the URLs. It’s not 100% necessary, but without it your rewrite will conflict with page permalinks. If you decide to use the static prefix, you might want to make it about the post type, since that’s what your taxonomies organize. I don’t know what that is, so I’m making a guess that it’s about “guides.” In that case, your URIs would be something like /guides/usa/diving/.
Here’s some code to get you started. If anything doesn’t make sense to you, you should watch the presentation and follow along with the slides.
It seems you’re using two non-hierarchical custom taxonomies. Try using a single hierarchical custom taxonomy (imagine how categories work). That way your URLs would be able to look like “usa/diving”.
When you register your custom taxonomy via your theme’s functions.php, do something like this:
The .php function is this
<?php get_term_link( $term, $taxonomy ); ?>
and here you have an example of how you can use this into your code:$terms = get_terms(‘species’);
It seems as though you actually have multiple options here.
Good luck!