• On my homepage I have the posted in: “category name” set up with the following code:

    <?php
    $category = get_the_category();
    if($category[0]){
    echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>';
    }
    ?>

    Just wondering, how can I add an if conditional statement in that (sorry not too PHP savvy):

    <?php if (is_category('blogging')) { ?>
    Make Money Blogging
    <?php } else { single_cat_title(); } ?>

    Basically, I want it to just get the post category URL linked by not the category name but my own defined name. So, for example, if the post is in the “blogging” category, I want it to link to that category page but with “Make Money Blogging” rather than just “Blogging” and I want to do this for more than just that one category, want to do that for two categories.

    Also, if possible, set a conditional statement so that if someone is browsing the category “Blogging” than the category name is not linked at all (but this is just if its possible — not really necessary).

    Hoping for a prompt response, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get Category Link of Post But Display Different Name?’ is closed to new replies.