• Resolved caflma

    (@caflma)


    On top of my post I can show the category to which the post belongs by using:

    <p><strong><?php the_category(', ') ?></strong></p>

    Let’s say my category is motorcycles, it would display –> motorcycles.

    How can I change the output to –> Read More Posts here

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can’t do that using the_category. You’ll have to use get_the_category and do something like what is described on that function’s Codex page.

    Thread Starter caflma

    (@caflma)

    If I use get_the_category, it shows “motorcycles” again.

    I want to link to the category “motorcycles” but the click-able link should read –> Read More Posts here

    No. get_the_category doesn’t show anything. It “returns an array…”. If it is echoing anything it is echoing because you’ve told it to echo. You need to loop through the array and create the links you want. Something like:

    <?php
    foreach((get_the_category()) as $category) {
        echo '<a href="'.get_category_link($category->cat_ID).'">Read More Posts Here</a>';
    }
    ?>
    Thread Starter caflma

    (@caflma)

    apljdi, thanks so much. It is working now!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change Wording of Category Link’ is closed to new replies.