Listing all custom taxonomy terms with an image
I’m trying to get all child terms of a custom taxonomy term and display them with their image, or without image if it’s not set.
For example: I have a custom post: Product and custom taxonomy Product Categories. Product Categories are setup like this:
Using above example, I would like to get all the categories that are child of Books and list them along with their thumbnail image.
Here’s the code I’m using:
$args = array( 'type' => 'post', 'child_of' => $category_id, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false ); $terms = apply_filters( 'taxonomy-images-get-terms', $args ); var_dump($terms);
Above is what I’m using to get the list of terms, but it only displays those with an image and excludes the ones without images. Is there a way I can get the entire list?
Is there a better way to achieve what I’m trying to do?
- The topic ‘Listing all custom taxonomy terms with an image’ is closed to new replies.