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 Marcinko
Ernest Marcinko
Keymaster

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

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;
}
Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)