WordPress.org

Ready to get started?Download WordPress

Forums

Link to current category using different anchor text (2 posts)

  1. Joshua Knowles
    Member
    Posted 3 years ago #

    I would like to link to the current category using different anchor text. I would like to do the same thing for the current tag. help please! thank you!

    [no bumping, please]

  2. Joshua Knowles
    Member
    Posted 3 years ago #

    Ok. So this is what I have so far:

    <?php
    $the_cat = get_the_category();
    $category_name = $the_cat[0]->cat_name;
    $category_description = $the_cat[0]->category_description;
    $category_link = get_category_link( $the_cat[0]->cat_ID );
    ?>
    
    <?php
    $the_tag = get_the_tags();
    $tag_name = $the_tag[0]->tag_name;
    $tag_description = $the_tag[0]->tag_description;
    $tag_link = get_tag_link( $the_tag[0]->tag_ID );
    ?>
    
    <a href="<?php echo $category_link; ?>">some text A</a> : <a href="<?php echo $tag_link; ?>">some text B</a>

    This code works fine on my tag pages but on my category pages the "some text B" link or the link that is suppose to link to the current corresponding tag page, links to the current category.

    Any help with this?

Topic Closed

This topic has been closed to new replies.

About this Topic