Last active
July 30, 2020 00:27
-
-
Save celsofabri/3a37fdd025e64e917114 to your computer and use it in GitHub Desktop.
Looping for Taxonomy / Looping para taxonomia
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 | |
$taxonomy = 'rota_categoria'; //Choose the taxonomy | |
$terms = get_terms( $taxonomy ); //Get all the terms | |
$queried_object = get_queried_object(); | |
$term_slug = $queried_object->slug; | |
$term_id = $queried_object->term_id; | |
$term_tax = $queried_object->term_taxonomy_id; | |
echo '<h1 class="title-tipo-roteiro">'. $queried_object->name .'</h1>'; | |
foreach ($terms as $term) { //Cycle through terms, one at a time | |
$args = array( | |
'posts_per_page' => -1, | |
'post_type' => 'vrrotas', | |
'term' => $term->slug, | |
'taxonomy' => $taxonomy, | |
); | |
$myquery = new WP_Query ( $args ); | |
// $article_count = $post->ID; | |
// Check and see if the term is a top-level parent. If so, display it. | |
$parent = $term->parent; | |
if ( $parent==$term_tax ) { | |
$term_id = $term->term_id; //Define the term ID | |
$term_link = get_term_link( $term, $taxonomy ); //Get the link to the archive page for that term | |
$term_name = $term->name; | |
// Box de Roteiros (Pacote) | |
echo '<div class="roteiros-box">'; | |
echo '<h3 class="title-roteiro title-search">'. $term->name .'</h3>'; | |
// Tipo de Rota Box | |
echo '<div class="roteiros-tipo-box">'; | |
// if ($article_count) { | |
while ($myquery->have_posts()) : $myquery->the_post(); | |
// Roteiro Box | |
echo '<a href="'; | |
the_permalink(); | |
echo '" title="'; | |
the_title(); | |
echo '" class="roteiro-box">'; | |
vr_thumb(235, 145, '', false, true, false); | |
// Rota de Destino | |
echo '<div class="rota">'; | |
echo '<h3 class="rota-title">'; | |
the_title(); | |
echo '</h3>'; | |
echo '</div>'; | |
// \ Rota de Destino | |
echo '</a>'; | |
// \ Roteiro Box | |
endwhile; | |
// } | |
echo '</div>'; | |
// \ Tipo de Rota Box | |
echo '</div>'; | |
// \ Box de Roteiros (Pacote) | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment