Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $posttags = get_the_tags();
- foreach($posttags as $tag) {
- if (is_numeric($tag->name)) {
- $unit_number = $tag->slug;
- echo '<p>History of tag ID: ', $unit_number, '</p>';
- $unit_history_args = array('post_type' => 'post',
- 'tax_query' => array(
- array( 'taxonomy' => 'post_tag',
- 'field' => 'slug',
- 'terms' => $unit_number,
- 'operator' => 'EXISTS',
- ),
- ),
- );
- $the_query = new WP_Query( $unit_history_args );
- if ( $the_query->have_posts() ) {
- echo '<ul>';
- while ( $the_query->have_posts() ) {
- $the_query->the_post();
- printf('<li><a href="%s">%s</a></li>', get_permalink(), get_the_title());
- }
- echo '</ul>';
- /* Restore original Post Data */
- wp_reset_postdata();
- } else {
- // no posts found
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement