Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 65051

How I can integrate with my custom code for related post in a single post page?

$
0
0

Replies: 0

<div id=”related_post”>
<?php
$related = get_posts(
array(
‘category__in’ => wp_get_post_categories( $post->ID ),
‘numberposts’ => 5,
‘post__not_in’ => array( $post->ID )
)
);

if( $related ) {
foreach( $related as $post ) {
setup_postdata($post);
?>
<h3><?php the_title();?></h3>
<?php the_post_thumbnail( ‘thumbnail’);?>
<?php the_excerpt( ); ?>
<?php
}
wp_reset_postdata();

}
?>
</div>
<
}
wp_reset_postdata();
}
</div>


Viewing all articles
Browse latest Browse all 65051

Trending Articles