Answer the question
In order to leave comments, you need to log in
Wordpress: Which link type is more correct for taxonomy terms?
Tell me how best to build links for taxonomy terms, for example, there is a custom post type 'news', it has a taxonomy 'news-cat' and the terms 'events', 'another' are in it.
As I see there are 2 options:
1) get_term_link( 'events', 'news-cat' ); to link to news category archive
2) do a rewrite in functions.php:
add_action('init', 'rewrite_news_cats');
function rewrite_news_cats(){
add_rewrite_tag('%news_cat%', '([^&]+)');
add_rewrite_rule('^(news)/([^/]*)/?', 'index.php?pagename=$matches[1]&news_cat=$matches[2]', 'top');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question