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 trial

WordPress

Loop 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

Not 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; ?>```

izzy goldman Many thanks! You've saved me hours of trial and error.

Please take a look at the WP Developer Reference Site