Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<li id="camera-brands" class="widget-container">
<h3 class="widget-title">Camera Brands</h3>
<?php $cam_brands = get_terms('brands', 'hide_empty=1'); ?>
<ul>
<?php foreach( $cam_brands as $brand ) : ?>
<li>
<a href="<?php echo get_term_link( $brand->slug, 'brands' ); ?>">
<?php echo $brand->name; ?>
</a>
<ul>
<?php
$wpq = array( 'post_type' => 'cameras', 'taxonomy' => 'brands', 'term' => $brand->slug );
$brand_posts = new WP_Query ($wpq);
?>
<?php foreach( $brand_posts->posts as $post ) : ?>
<li>
<a href="<?php echo get_permalink( $post->ID ); ?>">
<?php echo $post->post_title; ?>
</a>
</li>
<?php endforeach ?>
</ul>
</li>
<?php endforeach ?>
</ul>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.