How to related Post show in wordpress

How to related Post show in wordpress

How to related Post show in wordpress
How to related Post show in wordpress

How to related post show in wordpress is today discussed. Blog posting and any other post related post showing index page or any other page showing wordpress themes folder wp-contents and new folder create includes and showing code follows.

/public_html/wp-content/themes/themsname/includes/post-formats/related-posts.php

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();

foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts' => 4, // these are the number of related posts we want to display
'caller_get_posts'=>1,
'ignore_sticky_posts' => 1 // to exclude the sticky post
);
// WP_Query takes the same arguments as query_posts
$related_query = new WP_Query($args);
if ($related_query->have_posts()) {
?>

<?php $blog_related = of_get_option('blog_related'); ?>
<?php if($blog_related){?>
<h3><?php echo of_get_option('blog_related'); ?></h3>
<?php } else { ?>
<h3><?php _e('Related Posts','drivingSchool');?></h3>
<?php } ?>
<ul class="related-posts">
<?php
while ($related_query->have_posts()) : $related_query->the_post();
?>
<li>
<?php if(has_post_thumbnail()) { ?>
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full'); //get img URL
$image = aq_resize( $img_url, 140, 100, true ); //resize & crop img
?>
<figure class="featured-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a>
</figure>
<?php } ?>

<h6 class="relatedPost"><a href="<?php the_permalink() ?>" > <?php the_title();?> </a></h6>
</li>
<?php
endwhile;
?>
</ul>
<?php }
wp_reset_query();
}
?>
Single.php

Which page showing related  post just copy and past this code. and more wordpress functions click here

<?php get_template_part( 'includes/post-formats/related-posts' ); ?>
<?php comments_template('', true); ?>


How to related Post show in wordpress Developerinvention 5 of 5
How to related Post show in wordpress How to related Post show in wordpress How to related post show in wordpress is today discuss...

Share this

Related Posts

Previous
Next Post »

Xolo Offer