Skip to content

Instantly share code, notes, and snippets.

@alimoshen
Created January 29, 2018 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alimoshen/7091df992113978a8bfdadcf0e3bc3fc to your computer and use it in GitHub Desktop.
Save alimoshen/7091df992113978a8bfdadcf0e3bc3fc to your computer and use it in GitHub Desktop.
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