How to show related posts with Content Views Pro?

Since version 4.4.0, you can show related posts of any post easily, by adding the View shortcode with additional parameter to the post’s content editor.

1. Shortcodes To Show Related Posts

  • Show related posts in same category

    [pt_view id="VIEW_ID" cat="GET_CURRENT"]
  • Show related posts in same tag

    [pt_view id="VIEW_ID" tag="GET_CURRENT"]
  • Show related posts in same custom taxonomy “Testimonial”

    [pt_view id="VIEW_ID" taxonomy="testimonial" terms="GET_CURRENT"]

    You can replace “testimonial” by any custom taxonomy in your WordPress site.

  • Detect taxonomy of current post automatically to show related posts

    [pt_view id="VIEW_ID" taxonomy="GET_CURRENT" terms="GET_CURRENT"]
  • Limit the number of related posts to show

    [pt_view id="VIEW_ID" cat="GET_CURRENT" limit=4]

2. How to show related posts for each post automatically?

Please add this code to file functions.php in the theme’s folder:

// Content Views Pro - show related posts for each post
add_filter( 'the_content', 'cvp_theme_auto_show_related_posts', 999 );
function cvp_theme_auto_show_related_posts( $content ) {
	if ( is_single() ) {
		echo do_shortcode( '[pt_view id="VIEW_ID" cat="GET_CURRENT"]' );
		$content .= ob_get_clean();
	return $content;

Notice 1: please DO NOT replace GET_CURRENT with any value.

Notice 2: please replace VIEW_ID with ID of your View

Notice 3: it will show No posts found if there are no posts match the combination of shortcode parameters. In that case, please create new View for your purpose.

Notice 4: showing related posts by View doesn’t support Ajax pagination. It supports Non-Ajax pagination only.