Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

or

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.

David

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.