T
T
thehighhomie2018-02-16 18:35:26
WordPress
thehighhomie, 2018-02-16 18:35:26

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');
}

and it already has get_query_var('news_cat'); display posts via WP_Query.
I'm not sure that the second option is better when it is already possible to go to the archive, but the SEO specialist says that the archives are closed from indexing in the search engine + he needs a hierarchy in the url.
Tell me which direction to go?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question