Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get all terms
function filter_post_type_link($link, $post)
{
if ($post->post_type != 'expertise')
return $link;
if ($cats = get_the_terms($post->ID, 'expertise_type'))
{
$link = str_replace('%expertise_type%', get_taxonomy_parents(array_pop($cats)->term_id, 'expertise_type', false, '/', true), $link); // see custom function defined below
}
return $link;
}
add_filter('post_type_link', 'filter_post_type_link', 10, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment