Created
April 3, 2018 23:19
-
-
Save thiagotmendes/516dc53d094545025bc471b113318d16 to your computer and use it in GitHub Desktop.
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
<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