Guest User

Untitled

a guest
Jan 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2. $tags = wp_get_post_tags($post->ID);
  3. if ($tags) {
  4. echo 'Related Posts';
  5. $first_tag = $tags[0]->term_id;
  6. $args=array(
  7. 'tag__in' => array($first_tag),
  8. 'post__not_in' => array($post->ID),
  9. 'showposts'=>5,
  10. 'caller_get_posts'=>1,
  11. 'post_type' => array('food','travel')
  12. );
  13. $my_query = new WP_Query($args);
  14. if( $my_query->have_posts() ) {
  15. echo '<ul>';
  16. while ($my_query->have_posts()) : $my_query->the_post(); ?>
  17. <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  18. <?php
  19. endwhile;
  20. echo '</ul>';
  21. }
  22. }
  23. ?>
Add Comment
Please, Sign In to add comment