Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active October 24, 2018 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/fa6c0a6961e159f675698a9d1cafccb6 to your computer and use it in GitHub Desktop.
Save billerickson/fa6c0a6961e159f675698a9d1cafccb6 to your computer and use it in GitHub Desktop.
<?php
/**
* Related Posts
* @see https://www.billerickson.net/related-posts-with-searchwp/
*
*/
function be_related_posts() {
$loop = new WP_Query( array(
'post__in' => ea_get_related_posts( 3 ),
'orderby' => 'post__in',
) );
if( $loop->have_posts() ):
while( $loop->have_posts() ): $loop->the_post();
get_template_part( 'partials/archive' );
endwhile;
endif;
wp_reset_postdata();
}
add_action( 'genesis_after_entry', 'be_related_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment