Reputation: 2432
I have an archive page for a custom post type in a specific taxonomy. This can be achieved creating a taxonomy template under the naming structure of taxonomy-[custom_taxonomy_slug].php
The end URL for my archive page is http://mysite.con/taxonomy/term/?post_type=post_type
I'm hoping to write an htaccess rule that will allow my URLs to read /taxonomy/term/post_type/
instead of having the query parameter included. Also, what would be the equivalent on Nginx?
I have tried something like this so far with no luck:
RewriteRule ^([^/]*)$ /taxonomy/term/?post_type=$1 [L]
But I am really not good with regular expressions or htaccess rewriting, so it's no wonder that doesn't work.
Upvotes: 0
Views: 1669
Reputation: 1759
You don't need an htaccess rule, you need to add a new rewrite rule using WordPress rewrite API.
function yourplugin_custom_rewrite() {
add_rewrite_rule("^taxonomy/([^/]+)/([^/]+)",'index.php?post_type=$matches[2]&taxonomy=$matches[1]','top');
}
add_action('init','yourplugin_custom_rewrite');
replace "taxonomy" with your custom taxonomy slug and it will do the job.
Upvotes: 1