WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Change Category TItle in Link (2 posts)

  1. Virendar
    Member
    Posted 3 years ago #

    I am using the code

    <?php the_category(' '); ?>

    to put a Link to the category of the currently viewing post.

    The link uses the category name as the text.

    I want to use my own text for the link.

    IE :

    Click HERE to go to the category page!

    The text "HERE" should link to the category page, in same manner as
    <?php the_category(' '); ?> code.

  2. Virendar
    Member
    Posted 3 years ago #

    I figured it out

    <?php
    $category = get_the_category();
    echo '<a href="'.get_category_link($category[0]->cat_ID).'">
    TEXT HERE
    </a>'; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic