How to display one child category as a link? (3 posts)

  1. CharlieLivingston
    Posted 2 years ago #

    Hey folks,

    So using this code:

    $category = get_the_category();
    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.

  2. Pioneer Web Design
    Posted 2 years ago #

    Take a look at my post for a menu that outputs child categories, I think the basics will work for you modified for your usage. You can see how I grabbed the child categories.


  3. CharlieLivingston
    Posted 2 years ago #

    I've had a look at your code, but I'm afraid my knowledge of PHP isn't deep enough to be able to apply it to my own situation. Can you be any more specific, please?

    [No bumping. If it's that urgent, consider hiring someone.]

Topic Closed

This topic has been closed to new replies.

About this Topic