0
votes

I'm trying to output a list of custom taxonomies that I have created with custom post types. Here's a screenshot of what I'm trying to achieve:

enter image description here

Construction, Industrial and Office are the parent taxonomies (categories), and the ones below are their children.

Icons aside, I simply want to display a specific main taxonomy then, underneath it, display the children of that category.

But in two different parts so I can style the parent different to the children.

The taxonomy term is: job_listing_category - so I assume I can show job_listing_category('Construction') and then in the same div show: job_listing_category('Construction', 'children')

I know that's not the correct syntax, but I'm learning as I go.

It seems like a simple thing, but I can't seem to find a way to do it.

I have the below code which shows a list of all categories... So I somehow need to change this to show the children of just one of those categories...

    <?php
$terms = get_terms( 'job_listing_category', 'orderby=count&hide_empty=0' );
$count = count($terms);
if ( $count > 0 ){
 echo "<ul>";
 foreach ( $terms as $term ) {
   echo "<li>" . $term->name . "</li>";

 }
 echo "</ul>";
}
?>

Obviously, there's a lot more missing... I'd really appreciate any help. thanks all for taking the time to read :)

1

1 Answers

0
votes

Ok, I managed to get this working just about by using the below code:

<?php
$terms = get_terms( 'job_listing_category', 'parent=59' );
$count = count($terms);
if ( $count > 0 ){
 echo "<ul>";
 foreach ( $terms as $term ) {
   echo "<li>" . $term->name . "</li>";

 }
 echo "</ul>";
}
?>