WordPress.org

Support

Support » How-To and Troubleshooting » How to display one child category as a link?

How to display one child category as a link?

  • Hey folks,

    So using this code:

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

    Which I got from here: http://codex.wordpress.org/Function_Reference/get_the_category

    I’m able to show the first category as a link. The problem is, I only want to display child categories of the category with the id 106. I’m not sure how to do this. Any help appreciated.

    Here’s a link to my site where you can see the problem: underneath the themes you see the categories ‘Ecommerce’, ‘Business’, etc, those are fine. But then under Fable for example it says ‘Premium’ and links to the parent category. I don’t want it to do that. I want to display to the first child category of the parent category premium > premium themes which has the id 106.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display one child category as a link?’ is closed to new replies.
Skip to toolbar