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

Reply To: Not displaying related posts

#34550
Ernest MarcinkoErnest Marcinko
Keymaster

Thank you!

I have added the following custom code to the functions.php file in your actual theme directory:

function add_tags_to_rpp($post) {
	// Tags
	$tags = get_the_tags($post->id);
	if ( $tags !== false && count($tags) > 0 ) { 
		$tags_output = '';
		$tags = array_map(function($tag){return $tag->name;}, $tags);
		$tags_output = '<p style="font-size: 11px;"><strong>Tags:</strong> ' . implode(', ', $tags) . '</p>';
		$post->content = $tags_output . $post->content;
	}
	
	// Categories
	$tags = get_the_category($post->id);
	if ( $tags !== false && count($tags) > 0 ) {
		$tags_output = '';
		$tags = array_map(function($tag){return $tag->name;}, $tags);
		$tags_output = '<p style="font-size: 11px;"><strong>Categories:</strong> ' . implode(', ', $tags) . '</p>';
		$post->content = $tags_output . $post->content;
	}
	return $post;
}
add_filter( 'rpp_item_after_postprocessing', 'add_tags_to_rpp', 10, 1);

This will append the categories and tags list to the related posts content, where possible: https://i.imgur.com/khDVBRd.png