Created
January 17, 2012 03:35
-
-
Save billerickson/1624461 to your computer and use it in GitHub Desktop.
Manually Curated Related Posts - Display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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