Press "Enter" to skip to content

Add Custom Taxonomy Permalink Variables

Sometimes you might want to have the permalink of a post type include the taxonomy in the path. This is a pretty specific thing to want since by default something can belong to multiple taxonomies and the post will get the taxonomy path of the last category checked.

That being said, if you still want to do this then put this in your functions file:

Basically when WordPress is serving up a permalink it will look for the %product_category% variable. If it finds it, a list of the product_category taxonomy will be searched for the post in question. If it finds one then it will append the taxonomy slug before the post slug.

It’s a pretty nifty thing for certain circumstances where you know every post will have a certain taxonomy.

It also goes well with a piece of jQuery that limits a single term being checked on a taxonomy.

    Leave a Reply