Selecting related posts
if there are no 4 related posts, the code below will fill the number with random posts of random categories, and avoid duplicates: <div class=”my-related-posts”><h4>You may also be interested in…</h4><ul class=”relatedposts”> <?php $duplicates = array( $current_post ); $posts = get_posts( array( “posts_per_page’ => 4, ‘orderby’ => ‘rand’, ‘category’ => $category->term_id, ‘post__not_in’ => array( $current_post )) … Read more