Content Views Pro help you to show related posts easily.
Notices:
Please replace VIEW_ID with ID of your View.
To limit the number of related posts to show, please add limit parameter to the shortcode, for example:
[pt_view id="VIEW_ID" cat="GET_CURRENT" limit=6]
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.
1. Show related posts for All posts
-
To show related posts in Sidebar
Please add below shortcode to the Text widget in the sidebar:
-
Shortcode to show related posts from same Category as the current post:
[pt_view id="VIEW_ID" cat="GET_CURRENT"]
-
Shortcode to show related posts from same Tag as the current post:
[pt_view id="VIEW_ID" tag="GET_CURRENT"]
-
Shortcode to show related posts from same specific taxonomy as the current post:
[pt_view id="VIEW_ID" taxonomy="testimonial" terms="GET_CURRENT"]
please replace
testimonial
by the slug of specific taxonomy in your website. -
Shortcode to show related posts from all taxonomies of the current post:
[pt_view id="VIEW_ID" taxonomy="GET_CURRENT" terms="GET_CURRENT"]
-
Shortcode to show related posts from same Category as the current post:
-
To show related posts below the post content
Please add below code to the file functions.php in the theme’s folder:
// Content Views Pro - show related posts for posts 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; }This shortcode
[pt_view id="VIEW_ID" cat="GET_CURRENT"]
shows related posts from same Category as the current post.If you want to show from same tag/taxonomy, please replace this shortcode with another shortcode (as mentioned here).
-
To show related posts from same specific taxonomy as the current custom post, use this code:
// Content Views Pro - show related posts for custom post add_filter( 'the_content', 'cvp_theme_show_related_custom_post_specific', 999 ); function cvp_theme_show_related_custom_post_specific( $content ) { if ( is_singular( 'CUSTOM_POST_SLUG_HERE' ) ) { ob_start(); echo '<h3>Related posts</h3>'; echo do_shortcode( '[pt_view id="VIEW_ID" taxonomy="testimonial" terms="GET_CURRENT"]' ); $content .= ob_get_clean(); } return $content; }
please replace
testimonial
by the slug of specific taxonomy in your website.please replace
CUSTOM_POST_SLUG_HERE
with your custom post type slug. -
To show related posts from all taxonomies of the current custom post, use this code:
// Content Views Pro - show related posts for 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_SLUG_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; }
please replace
CUSTOM_POST_SLUG_HERE
with your custom post type slug.
-
To show related posts from same specific taxonomy as the current custom post, use this code:
2. Show related posts for specific posts
To show related posts for only some specific posts, please edit these posts, then add shortcode (choose the shortcode here depends on your need) to the post content area.
3. Show related posts for custom post type (product, event, …)
-
To show related posts in Sidebar
Please add below shortcode to the Text widget in the sidebar:
-
Shortcode to show related posts from same Category as the current post:
[pt_view id="VIEW_ID" cat="GET_CURRENT"]
-
Shortcode to show related posts from same Tag as the current post:
[pt_view id="VIEW_ID" tag="GET_CURRENT"]
-
Shortcode to show related posts from same specific taxonomy as the current post:
[pt_view id="VIEW_ID" taxonomy="testimonial" terms="GET_CURRENT"]
please replace
testimonial
by the slug of specific taxonomy in your website. -
Shortcode to show related posts from all taxonomies of the current post:
[pt_view id="VIEW_ID" taxonomy="GET_CURRENT" terms="GET_CURRENT"]
-
Shortcode to show related posts from same Category as the current post:
-
To show related posts below the post content
Please add below code to the file functions.php in the theme’s folder:
// Content Views Pro - show related posts for posts 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; }This shortcode
[pt_view id="VIEW_ID" cat="GET_CURRENT"]
shows related posts from same Category as the current post.If you want to show from same tag/taxonomy, please replace this shortcode with another shortcode (as mentioned here).
-
To show related posts from same specific taxonomy as the current custom post, use this code:
// Content Views Pro - show related posts for custom post add_filter( 'the_content', 'cvp_theme_show_related_custom_post_specific', 999 ); function cvp_theme_show_related_custom_post_specific( $content ) { if ( is_singular( 'CUSTOM_POST_SLUG_HERE' ) ) { ob_start(); echo '<h3>Related posts</h3>'; echo do_shortcode( '[pt_view id="VIEW_ID" taxonomy="testimonial" terms="GET_CURRENT"]' ); $content .= ob_get_clean(); } return $content; }
please replace
testimonial
by the slug of specific taxonomy in your website.please replace
CUSTOM_POST_SLUG_HERE
with your custom post type slug. -
To show related posts from all taxonomies of the current custom post, use this code:
// Content Views Pro - show related posts for 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_SLUG_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; }
please replace
CUSTOM_POST_SLUG_HERE
with your custom post type slug.
-
To show related posts from same specific taxonomy as the current custom post, use this code:
If you have any questions or need help, please contact us here.