This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: How to display post's category on related posts

Home Forums Product Support Forums Related Posts Pro for WordPress Support How to display post's category on related posts Reply To: How to display post's category on related posts

#7166
Ernest MarcinkoErnest Marcinko
Keymaster

Actually, yes, and it’s probably better that way. Try changing the whole thing to this:

[php]add_filter( ‘rpp_item_after_postprocessing’, ‘rpp_add_category_titles’, 1, 1 );

function rpp_add_category_titles( $post ) {

// Get the post categories
$post_categories = wp_get_post_categories( $post->id );
$cats = array();

// Concatenate category names to the $cats variable
foreach($post_categories as $c){
$cat = get_category( $c );
$cats[] = $cat->name;
}

if ( count($cats) )
$post->author = implode(", ", $cats);

return $post;
}[/php]