Related Posts
-
ID);
if ($categories) {
$cat_ids = array();
foreach ($categories as $category) {
$cat_ids[] = $category->term_id;
}
$related_query = new WP_Query(array(
'category__in' => $cat_ids,
'post__not_in' => array($post->ID),
'posts_per_page' => 5,
));
if ($related_query->have_posts()) {
while ($related_query->have_posts()) {
$related_query->the_post();
echo '
- ' . get_the_title() . ' '; } } else { echo '
- No related posts found. '; } wp_reset_postdata(); } ?>