WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Working on an SEO plugin and stuck on something I thought would be simple.

Looking for code to generate just the URLs for categories, tags, search, and date archives when on that archive set. So if on category ABC there's the URL to www.domain.com/category/abc/

Was hoping it was something simple like this for the categories part:

echo get_category_link($cat->term_id);


echo get_category_link($category->term_id);

but apparently not.

The general code works if I add a specific category

echo get_category_link(123);

The plugin adds code to the head via wp_head()

The plugin (if I ever finish it) will be a replacement for so called SEO plugins that use noindex and nofollow to 'sculpt' PR/protect link benefit. Noindex wastes link benefit, nofollow deletes link benefit so they shouldn't be used.


share|improve this question
up vote 1 down vote accepted

in a category archive, the code could be:

echo get_category_link(get_query_var('cat')); 

in a tag archive, this could be:

if(is_tag()) echo get_term_link(get_query_var('tag'), 'post_tag');

the conditional was added to avoid an error messages if not in a tag archive.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.