Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134460

CharlieLivingston on "How to display one child category as a link?"

$
0
0

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 all articles
Browse latest Browse all 134460

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>