{"id":1436,"date":"2017-03-09T12:25:09","date_gmt":"2017-03-09T12:25:09","guid":{"rendered":"http:\/\/docs.contentviewspro.com\/?p=1436"},"modified":"2024-04-05T09:58:56","modified_gmt":"2024-04-05T09:58:56","password":"","slug":"show-related-posts-content-views-pro","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/show-related-posts-content-views-pro\/","title":{"rendered":"Show related posts"},"content":{"rendered":"\n<style>\n.custompost {display: none;}\n.for-custom-post ~ ul .custompost {display: block !important;}\n.for-custom-post ~ ul .postonly {display: none !important;}\n.postid-1436 pre {margin-top: 10px; padding: 5px; font-size: 14px;}\n.postid-1436 p {margin-bottom: 10px;}\nul li ul {list-style: circle;}\n<\/style>\n\n\n\n\n<p class=\"wp-block-paragraph\">Content Views Pro help you to show related posts easily.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Notices:<\/h2>\n\n\n\n<blockquote><p>Please replace <strong>VIEW_ID<\/strong> with <a href=\"https:\/\/contentviewspro.com\/documentation\/article\/what-is-id-of-a-view\/\" target=\"_blank\" rel=\"noopener\">ID of your View<\/a>.<\/p><\/blockquote>\n\n<blockquote><p>To limit the number of related posts to show, please add <strong>limit<\/strong> parameter to the shortcode, for example: <code>[pt_view id=\"VIEW_ID\" cat=\"GET_CURRENT\" limit=6]\n<\/code><\/p><\/blockquote>\n\n<blockquote><p>It will show <strong>No posts found<\/strong> if there are no posts match the combination of shortcode parameters, or the parameter value was wrong.<\/p><\/blockquote>\n\n<blockquote><p>Showing related posts by View <strong>doesn&#8217;t support Ajax pagination<\/strong>. It supports Normal pagination only.<\/p><\/blockquote>\n\n<blockquote><p>To hide the current post from related posts list, please select the checkbox \u201cExclude current post\u201d in the View.<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">1. Show related posts for All posts<\/h2>\n\n\n\n<ul>\n\t<li>\n\t\t<h4>To show related posts in Sidebar<\/h4>\n\t\t<p>Please add below shortcode to the <b>Text widget<\/b> in the sidebar:<\/p>\n\t\t\n\t\t<ul id=\"allshortcode\">\n\t\t\t<li class=\"postonly\">\n\t\t\tShortcode to show related posts from same <b>Category<\/b> as the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" cat=\"GET_CURRENT\"]<\/pre>\n\t\t\t<\/li>\n\t\t\t\n\t\t\t<li class=\"postonly\">\n\t\t\tShortcode to show related posts from same <b>Tag<\/b> as the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" tag=\"GET_CURRENT\"]<\/pre>\n\t\t\t<\/li>\n\t\t\t\n\t\t\t<li>\n\t\t\tShortcode to show related posts from same <b>specific taxonomy<\/b> as the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" taxonomy=\"testimonial\" terms=\"GET_CURRENT\"]<\/pre>\n\n\t\t\t<p>please replace <code>testimonial<\/code> by the <a href=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy.png\" target=\"_blank\" rel=\"noopener noreferrer\">slug of specific taxonomy<\/a> in your website.<\/p>\n\t\t\t<\/li>\n\t\t\t\n\t\t\t<li>\n\t\t\tShortcode to show related posts from <b>all taxonomies<\/b> of the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" taxonomy=\"GET_CURRENT\" terms=\"GET_CURRENT\"]<\/pre>\n\t\t\t<\/li>\n\t\t<\/ul>\n\t<\/li>\n\t<li>\n\t\t<h4>To show related posts below the post content<\/h4>\n\t\t<p>Please add below code to the file <b>functions.php<\/b> in the theme\u2019s folder:<\/p>\n\n<div class=\"postonly\">\n<pre>\n\/\/ Content Views Pro - show related posts for posts\nadd_filter( 'the_content', 'cvp_theme_auto_show_related_posts', 999 );\nfunction cvp_theme_auto_show_related_posts( $content ) {\n\tif ( is_single() ) {\n\t\tob_start();\n\t\techo '&lt;h3&gt;Related posts&lt;\/h3&gt;';\n\t\techo do_shortcode( ' <code>[pt_view id=\"VIEW_ID\" cat=\"GET_CURRENT\"]<\/code> ' );\n\t\t$content .= ob_get_clean();\n\t}\n\treturn $content;\n}\n<\/pre>\n\n<p>This shortcode <code>[pt_view id=\"VIEW_ID\" cat=\"GET_CURRENT\"]<\/code> shows related posts from same <b>Category<\/b> as the current post.<\/p>\n<p>If you want to show from same tag\/taxonomy, please replace this shortcode with another shortcode (<a href=\"#allshortcode\">as mentioned here<\/a>).<\/p>\n<\/div>\n\n<div class=\"custompost\">\n\t<ul>\n\t\t<li>\n\t\t\tTo show related posts from same <b>specific taxonomy<\/b> as the current custom post, use this code: <br\/>\t\t\t\n<pre>\n\/\/ Content Views Pro - show related posts for custom post\nadd_filter( 'the_content', 'cvp_theme_show_related_custom_post_specific', 999 );\nfunction cvp_theme_show_related_custom_post_specific( $content ) {\n\tif ( is_singular( 'CUSTOM_POST_SLUG_HERE' ) ) {\n\t\tob_start();\n\t\techo '&lt;h3&gt;Related posts&lt;\/h3&gt;';\n\t\techo do_shortcode( '[pt_view id=\"VIEW_ID\" taxonomy=\"testimonial\" terms=\"GET_CURRENT\"]' );\n\t\t$content .= ob_get_clean();\n\t}\n\treturn $content;\n}\n<\/pre>\n\t\t\t<p>please replace <code>testimonial<\/code> by the <a href=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy.png\" target=\"_blank\" rel=\"noopener noreferrer\">slug of specific taxonomy<\/a> in your website.<\/p>\n\n\t\t\t<p>please replace <code>CUSTOM_POST_SLUG_HERE<\/code> with your custom post type slug.<\/p>\n\t\t<\/li>\n\t\t\t\n\t\t<li>\n\t\t\tTo show related posts from <b>all taxonomies<\/b> of the current custom post, use this code: <br\/>\t\t\t\n<pre>\n\/\/ Content Views Pro - show related posts for custom post\nadd_filter( 'the_content', 'cvp_theme_auto_show_related_custom_posts', 999 );\nfunction cvp_theme_auto_show_related_custom_posts( $content ) {\n\tif ( is_singular( 'CUSTOM_POST_SLUG_HERE' ) ) {\n\t\tob_start();\n\t\techo '&lt;h3&gt;Related posts&lt;\/h3&gt;';\n\t\techo do_shortcode( '[pt_view id=\"VIEW_ID\" taxonomy=\"GET_CURRENT\" terms=\"GET_CURRENT\"]' );\n\t\t$content .= ob_get_clean();\n\t}\n\treturn $content;\n}\n<\/pre>\n\n\t\t\t<p>please replace <code>CUSTOM_POST_SLUG_HERE<\/code> with your custom post type slug.<\/p>\n\t\t<\/li>\n\t<\/ul>\n<\/div>\n\t<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. Show related posts for specific posts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To show related posts for only some specific posts, please edit these posts, then add shortcode (<a href=\"#allshortcode\">choose the shortcode here depends on your need<\/a>) to the post content area.<\/p>\n\n\n\n<h2 class=\"wp-block-heading for-custom-post\">3. Show related posts for custom post type (product, event, \u2026)<\/h2>\n\n\n\n<ul>\n\t<li>\n\t\t<h4>To show related posts in Sidebar<\/h4>\n\t\t<p>Please add below shortcode to the <b>Text widget<\/b> in the sidebar:<\/p>\n\t\t\n\t\t<ul id=\"allshortcode\">\n\t\t\t<li class=\"postonly\">\n\t\t\tShortcode to show related posts from same <b>Category<\/b> as the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" cat=\"GET_CURRENT\"]<\/pre>\n\t\t\t<\/li>\n\t\t\t\n\t\t\t<li class=\"postonly\">\n\t\t\tShortcode to show related posts from same <b>Tag<\/b> as the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" tag=\"GET_CURRENT\"]<\/pre>\n\t\t\t<\/li>\n\t\t\t\n\t\t\t<li>\n\t\t\tShortcode to show related posts from same <b>specific taxonomy<\/b> as the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" taxonomy=\"testimonial\" terms=\"GET_CURRENT\"]<\/pre>\n\n\t\t\t<p>please replace <code>testimonial<\/code> by the <a href=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy.png\" target=\"_blank\" rel=\"noopener noreferrer\">slug of specific taxonomy<\/a> in your website.<\/p>\n\t\t\t<\/li>\n\t\t\t\n\t\t\t<li>\n\t\t\tShortcode to show related posts from <b>all taxonomies<\/b> of the current post: <br\/>\n\t\t\t<pre>[pt_view id=\"VIEW_ID\" taxonomy=\"GET_CURRENT\" terms=\"GET_CURRENT\"]<\/pre>\n\t\t\t<\/li>\n\t\t<\/ul>\n\t<\/li>\n\t<li>\n\t\t<h4>To show related posts below the post content<\/h4>\n\t\t<p>Please add below code to the file <b>functions.php<\/b> in the theme\u2019s folder:<\/p>\n\n<div class=\"postonly\">\n<pre>\n\/\/ Content Views Pro - show related posts for posts\nadd_filter( 'the_content', 'cvp_theme_auto_show_related_posts', 999 );\nfunction cvp_theme_auto_show_related_posts( $content ) {\n\tif ( is_single() ) {\n\t\tob_start();\n\t\techo '&lt;h3&gt;Related posts&lt;\/h3&gt;';\n\t\techo do_shortcode( ' <code>[pt_view id=\"VIEW_ID\" cat=\"GET_CURRENT\"]<\/code> ' );\n\t\t$content .= ob_get_clean();\n\t}\n\treturn $content;\n}\n<\/pre>\n\n<p>This shortcode <code>[pt_view id=\"VIEW_ID\" cat=\"GET_CURRENT\"]<\/code> shows related posts from same <b>Category<\/b> as the current post.<\/p>\n<p>If you want to show from same tag\/taxonomy, please replace this shortcode with another shortcode (<a href=\"#allshortcode\">as mentioned here<\/a>).<\/p>\n<\/div>\n\n<div class=\"custompost\">\n\t<ul>\n\t\t<li>\n\t\t\tTo show related posts from same <b>specific taxonomy<\/b> as the current custom post, use this code: <br\/>\t\t\t\n<pre>\n\/\/ Content Views Pro - show related posts for custom post\nadd_filter( 'the_content', 'cvp_theme_show_related_custom_post_specific', 999 );\nfunction cvp_theme_show_related_custom_post_specific( $content ) {\n\tif ( is_singular( 'CUSTOM_POST_SLUG_HERE' ) ) {\n\t\tob_start();\n\t\techo '&lt;h3&gt;Related posts&lt;\/h3&gt;';\n\t\techo do_shortcode( '[pt_view id=\"VIEW_ID\" taxonomy=\"testimonial\" terms=\"GET_CURRENT\"]' );\n\t\t$content .= ob_get_clean();\n\t}\n\treturn $content;\n}\n<\/pre>\n\t\t\t<p>please replace <code>testimonial<\/code> by the <a href=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy.png\" target=\"_blank\" rel=\"noopener noreferrer\">slug of specific taxonomy<\/a> in your website.<\/p>\n\n\t\t\t<p>please replace <code>CUSTOM_POST_SLUG_HERE<\/code> with your custom post type slug.<\/p>\n\t\t<\/li>\n\t\t\t\n\t\t<li>\n\t\t\tTo show related posts from <b>all taxonomies<\/b> of the current custom post, use this code: <br\/>\t\t\t\n<pre>\n\/\/ Content Views Pro - show related posts for custom post\nadd_filter( 'the_content', 'cvp_theme_auto_show_related_custom_posts', 999 );\nfunction cvp_theme_auto_show_related_custom_posts( $content ) {\n\tif ( is_singular( 'CUSTOM_POST_SLUG_HERE' ) ) {\n\t\tob_start();\n\t\techo '&lt;h3&gt;Related posts&lt;\/h3&gt;';\n\t\techo do_shortcode( '[pt_view id=\"VIEW_ID\" taxonomy=\"GET_CURRENT\" terms=\"GET_CURRENT\"]' );\n\t\t$content .= ob_get_clean();\n\t}\n\treturn $content;\n}\n<\/pre>\n\n\t\t\t<p>please replace <code>CUSTOM_POST_SLUG_HERE<\/code> with your custom post type slug.<\/p>\n\t\t<\/li>\n\t<\/ul>\n<\/div>\n\t<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you have any questions or need help, please <a href=\"https:\/\/www.contentviewspro.com\/contact\/\" target=\"_blank\" rel=\"noreferrer noopener\">contact us here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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=&#8221;VIEW_ID&#8221; cat=&#8221;GET_CURRENT&#8221; limit=6] It will show No posts found if there are no posts match the combination &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/show-related-posts-content-views-pro\/\"> <span class=\"screen-reader-text\">Show related posts<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"doc_category":[45],"doc_tag":[],"class_list":["post-1436","docs","type-docs","status-publish","hentry","doc_category-popular-features"],"year_month":"2026-09","word_count":165,"total_views":"8","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin1","author_nicename":"admin1","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/admin1\/"},"doc_category_info":[{"term_name":"Popular Features","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/popular-features\/"}],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/1436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=1436"}],"version-history":[{"count":23,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/1436\/revisions"}],"predecessor-version":[{"id":5887,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/1436\/revisions\/5887"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=1436"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=1436"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=1436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}