Created
October 19, 2011 00:16
-
-
Save davemac/1297140 to your computer and use it in GitHub Desktop.
WordPress query taxonomy by meta key and value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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