Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active February 3, 2016 16:29
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/1624451 to your computer and use it in GitHub Desktop.
Save billerickson/1624451 to your computer and use it in GitHub Desktop.
Manually Curated Related Posts - Pre-Loop Code
<?php
/**
* Related Posts Before Loop
* Adds connection data to $wp_query. Run before the loop.
*
* @author Bill Erickson
* @link http://www.billerickson.net/manually-curated-related-posts/
*/
function be_related_posts_pre_loop() {
// Make Sure plugin is active
if ( !function_exists( 'p2p_register_connection_type' ) )
return;
global $wp_query;
p2p_type( 'related-articles' )->each_connected( $wp_query );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment