Skip to content

Instantly share code, notes, and snippets.

@luiseduardobraschi
Created March 8, 2018 05:39
Show Gist options
  • Save luiseduardobraschi/db07033a9bf53e3a1090ff4fad8013aa to your computer and use it in GitHub Desktop.
Save luiseduardobraschi/db07033a9bf53e3a1090ff4fad8013aa to your computer and use it in GitHub Desktop.
Adding taxonomy filtering to a loop
<?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