Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 17, 2012 03:35
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/1624461 to your computer and use it in GitHub Desktop.
Save billerickson/1624461 to your computer and use it in GitHub Desktop.
Manually Curated Related Posts - Display
<?php
/**
* Display Related Posts
* @author Bill Erickson
* @link http://www.billerickson.net/manually-curated-related-posts/
*/
function be_related_posts() {
// Make Sure plugin is active
if ( !function_exists( 'p2p_register_connection_type' ) )
return;
global $post;
if( isset( $post->connected ) && !empty( $post->connected ) ):
echo '<div class="related-posts">';
$count = 1;
foreach( $post->connected as $related ):
if( $count < 6 ) {
echo '<div class="related-post">';
echo '<a class="image" href="' . get_permalink( $related->ID ) . '">';
$cat = wp_get_object_terms( $related->ID, 'category', array( 'count' => 1 ) );
echo '<span class="category">' . $cat[0]->name . '</span>';
echo get_the_post_thumbnail( $related->ID, 'be_home_small' );
echo '</a>';
echo '<a class="title" href="' . get_permalink( $related->ID ) . '">' . $related->post_title . '</a>';
echo '</div>';
$count++;
}
endforeach;
echo '</div>';
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment