Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <section class="similar">
- <h4>Similar</h4>
- <ul class="posts">
- <?php
- $tags = wp_get_post_tags($post->ID);
- if ($tags) {
- foreach( $tags as $tag) { $first_tag[] = $tag->term_id; } //NEW
- $s_args=array(
- 'category_name' => parent_category(),
- 'tag__in' => $first_tag, //NEW CHANGE
- 'post__not_in' => array($post->ID),
- 'showposts' => 4,
- 'caller_get_posts' => 1
- );
- $similar = new WP_Query($s_args);
- $not_to_dupe = array($post->ID); //NEW
- if ($similar->have_posts()) {
- while ($similar->have_posts()) : $similar->the_post();
- $not_to_dupe[] = $post->ID; //NEW
- get_template_part('loop', '');
- endwhile;
- };
- }; ?>
- </ul>
- </section>
- <section class="popular">
- <h4>Popular</h4>
- <ul class="posts">
- <?php
- $p_args = array(
- 'category_name' => parent_category(),
- 'orderby' => 'comment_count',
- 'post__not_in' => $not_to_dupe, //NEW
- 'posts_per_page' => 4
- );
- $popular = new WP_Query($p_args);
- while ($popular->have_posts()) : $popular->the_post();
- get_template_part('loop', '');
- endwhile;
- ?>
- </ul>
- </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement