Since Pro version 4.4.0, you can show related posts of any post easily.

To do it for specific posts, please add the below shortcodes to the post content.
To do it automatically for all posts or custom posts, please check the code below.

  • Show related posts in same category as the current post

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

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

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

    You can replace “testimonial” by slug of another 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]
    

Notices

Please DO NOT replace GET_CURRENT with any value.

Please replace VIEW_ID with ID of your View.

It will show No posts found if there are no posts match the combination of shortcode parameters, or the parameter value was wrong.

Showing related posts by View doesn't support Ajax pagination. It supports Normal pagination only.

To hide the current post from related posts list, please select the checkbox “Exclude current post” in the View.

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() ) {
		ob_start();
		echo '<h3>Related posts</h3>';
		echo do_shortcode( '[pt_view id="VIEW_ID" cat="GET_CURRENT"]' );
		$content .= ob_get_clean();
	}
	return $content;
}

3. How to show related posts for each Custom post (product, event, …) automatically?

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

// Content Views Pro - show related posts for each custom post
add_filter( 'the_content', 'cvp_theme_auto_show_related_custom_posts', 999 );
function cvp_theme_auto_show_related_custom_posts( $content ) {
	if ( is_singular( 'CUSTOM_POST_HERE' ) ) {
		ob_start();
		echo '<h3>Related posts</h3>';
		echo do_shortcode( '[pt_view id="VIEW_ID" taxonomy="GET_CURRENT" terms="GET_CURRENT"]' );
		$content .= ob_get_clean();
	}
	return $content;
}

(replace CUSTOM_POST_HERE with the name of your custom post type)


Scroll to Top