Created
March 8, 2018 05:39
-
-
Save luiseduardobraschi/db07033a9bf53e3a1090ff4fad8013aa to your computer and use it in GitHub Desktop.
Adding taxonomy filtering to a loop
This file contains 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 | |
$args = array( | |
'post_type' => 'cardapio', | |
'posts_per_page' => 999, | |
'orderby' => 'title', | |
'order' => 'ASC', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'cardapio_category', | |
'field' => 'term_id', | |
'terms' => array(3), | |
), | |
), | |
); | |
$cardapiohome = new WP_Query ( $args ); | |
?> | |
<div class="row"> | |
<?php if($cardapiohome->have_posts()) : while ($cardapiohome->have_posts()) : $cardapiohome->the_post(); ?> | |
<!-- LOOP --> | |
<div class="col-sm-6"> | |
<div class="bloco-cardapio"> | |
<div class="conteudo-cardapio"> | |
<h2><?php the_title(); ?></h2> | |
<?php the_content(); ?> | |
</div> | |
</div> | |
</div> | |
<!--// LOOP --> | |
<?php endwhile; wp_reset_postdata(); ?> | |
</div> | |
<?php else: ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment