Header Ads

HOW TO SHOW RELATED POST ON WORDPRESS 2




METHOD 2.
Showing Related Posts in WordPress without you using a Plugin

Did you miss the first method? Click Below




Copy and Paste the following code in single.php where you may want to display related posts



<?php
//for use in the loop, list 7 post titles related to first tag on current post $tags = wp_get_post_tags($post->ID); if ($tags) { echo 'Related Posts';
'post__not_in' => array($post->ID), $first_tag = $tags[0]->term_id; $args=array( 'tag__in' => array($first_tag), 'posts_per_page'=>7,
while ($my_query->have_posts()) : $my_query->the_post(); ?> 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) {
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php endwhile; } wp_reset_query(); }
?>







Want to receive our next updates? Enter your email address:

Delivered by Ideasbeams


No comments

We appreciate your comment a lot. You can join our facebook group to stay up-to-date with us.
Have any inquiries, feel free to use the contact page. Thank you.

FOR BLOGGERS
Click To Parse Your Adsense HTML Code
Powered by Blogger.