Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjessebraddock
60 PointsLoop through custom taxonomy on front page?
I just completed the WP theming course and it was terrific! To go one step further, how can I get a custom taxonomy query on the front page and output posts / custom posts mapped to that taxonomy? Or is this solution in another course? Thanks!
3 Answers
izzy goldman
12,542 PointsNot sure if this helps. But i tend to use a simple foreach.
$terms = get_terms( 'custom_taxonomy_name', array(
'hide_empty' => true,
)
);
?>
<?php foreach( $terms as $term ) : ?>
<a href="<?php echo $term->slug;?>"><?php echo $term->name;?></a>
<?php endforeach; ?>```
jessebraddock
60 Pointsizzy goldman Many thanks! You've saved me hours of trial and error.
Jacob Mishkin
23,118 PointsPlease take a look at the WP Developer Reference Site