Advertisement
wdtobibur

Related Post

Oct 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. #######################
  2.  
  3. Related Post......
  4.  
  5. <!-- start related projects -->
  6. <div id="related-projects">
  7. <!-- start related project title -->
  8. <header class="content-header v3">
  9. <h4>Similar Post</h4>
  10. </header>
  11. <!-- end related project title -->
  12. <?php
  13. //for use in the loop, list 5 post titles related to first tag on current post
  14. $tags = wp_get_post_tags($post->ID);
  15. if ($tags) {
  16. $first_tag = $tags[0]->term_id;
  17. $args=array(
  18. 'tag__in' => array($first_tag),
  19.  
  20. 'posts_per_page'=>3,
  21. 'ignore_sticky_posts' => 1,
  22. 'post__in' => get_option( $post->ID ),
  23. );
  24. };
  25. $reladet_post = new WP_Query($args);
  26. if( $reladet_post->have_posts() ) :
  27.  
  28. ?>
  29.  
  30. <!-- start projects -->
  31. <div class="projects row">
  32. <?php while ($reladet_post->have_posts()) : $reladet_post->the_post(); ?>
  33. <!-- project 1 -->
  34. <div class="col-24 web">
  35. <article class="project">
  36. <figure class="project-thumb">
  37. <?php the_post_thumbnail('reladet_img'); ?>
  38. </figure>
  39.  
  40. <header class="project-header">
  41. <h4 class="project-title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h4>
  42. <div class="project-meta"><?php the_category(' '); ?></div>
  43. </header>
  44. </article>
  45. </div>
  46.  
  47. <?php endwhile;?>
  48. </div>
  49. <!-- end projects -->
  50. <?php endif;?>
  51. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement