Get postings from the parent post term
-
With the following code I give out all postings of my pd “release” with the taxonomy “kategorie”.
But how can I get it now, if I wanna do the same (example on an single page) from the parent term (of taxonomy) ?
<?php $terms_array = array( 'taxonomy' => 'kategorie', 'orderby' => 'ID', 'order' => 'ASC', ); $services_terms = get_terms($terms_array); foreach($services_terms as $service): ?> <div id="content_releases"> <div class="kategorie"> <span> <?php if (get_locale() == 'en_US') { echo $service->name; echo '<span>'; echo '<a href="/releases/'; echo $service->slug; echo '"'; echo ' target="_parent">'; echo 'view all'; echo ' '; echo $service->name; echo '</a>'; echo '</span>'; }?> <?php if (get_locale() == 'de_DE') { echo $service->name; echo '<span>'; echo '<a href="/de/releases/'; echo $service->slug; echo '"'; echo ' target="_parent">'; echo 'alle'; echo ' '; echo $service->name; echo ' '; echo 'ansehen'; echo '</a>'; echo '</span>'; }?> <?php if (get_locale() == 'es_ES') { echo $service->name; echo '<span>'; echo '<a href="/es/releases/'; echo $service->slug; echo '"'; echo ' target="_parent">'; echo 'ver todos'; echo ' '; echo $service->name; echo '</a>'; echo '</span>'; }?> </span> <div class="clear"></div> </div> <?php $post_args = array( 'posts_per_page' => '5', 'post_type' => 'release', 'tax_query' => array( array( 'taxonomy' => 'kategorie', 'field' => 'term_id', 'terms' => $service->term_id, ) ) ); $myposts = get_posts($post_args); ?> <?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <div class="release_wrap"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a> <h2><a href="<?php the_permalink(); ?>"><?php echo pods_field_display( 'voe_titel' );?></a> von <?php echo pods_field_display( 'artist' );?> <?php echo pods_field_display( 'featuring_angabe' );?> <?php echo pods_field_display( 'featuring_artist' );?></h2> </div> <?php endforeach; // Term Post foreach ?> <div class="clear"></div> <?php wp_reset_postdata(); ?> <?php endforeach; // End Term foreach; ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Get postings from the parent post term’ is closed to new replies.