Skip to content

Instantly share code, notes, and snippets.

@thiagotmendes
Created April 3, 2018 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagotmendes/516dc53d094545025bc471b113318d16 to your computer and use it in GitHub Desktop.
Save thiagotmendes/516dc53d094545025bc471b113318d16 to your computer and use it in GitHub Desktop.
<div class="container">
<?php
$terms = get_terms( 'categoria-cursos', array(
'hide_empty' => false,
) );
// var_dump($terms);
foreach ($terms as $termos) {
echo "<h3>".$termos->name."</h3>";
$argCursoPorCategoria = array(
'post_type' => 'cursos',
'tax_query' => array(
array(
'taxonomy' => 'categoria-cursos',
'field' => 'slug',
'terms' => $termos->slug,
)
)
);
$cursos = new WP_Query($argCursoPorCategoria);
if ($cursos->have_posts()) {
while($cursos->have_posts()){ $cursos->the_post();
echo "<h4>".the_title()."</h4>";
}
} else {
echo "Nenhum curso encontrado para esta categoria";
}
echo "<hr>";
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment