Skip to content

Instantly share code, notes, and snippets.

@davemac
Created October 19, 2011 00:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemac/1297140 to your computer and use it in GitHub Desktop.
Save davemac/1297140 to your computer and use it in GitHub Desktop.
WordPress query taxonomy by meta key and value
<?php
$myquery = array(
'tax_query' => array(
array(
'taxonomy' => 'productcat',
'terms' => array('equip', 'pro-rack', 'slat-tech', 'acrylics' , 'i60-system' , 'prestige', 'shop-x', 'shopfitters'),
'field' => 'slug'
)
),
'order' => 'ASC',
'meta_key' => 'feature-on-homepage',
'meta_value' => 'Yes'
);
$showFeaturedProduct = new WP_Query( $myquery );
?>
<?php
while ($showFeaturedProduct->have_posts()) : $showFeaturedProduct->the_post();
?>
<div class="one_third">
<?php if ((has_post_thumbnail()) ) { ?>
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail('front-post-thumbnail'); ?></a>
<?php } ?>
<h2><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment