{"id":116,"date":"2014-08-17T10:08:00","date_gmt":"2014-08-17T10:08:00","guid":{"rendered":"http:\/\/docs.contentviewspro.com\/\/?p=116"},"modified":"2023-12-28T08:24:10","modified_gmt":"2023-12-28T08:24:10","password":"","slug":"reuse-a-view","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/reuse-a-view\/","title":{"rendered":"Reuse View shortcode (add parameters)"},"content":{"rendered":"<style>p {margin-bottom: 1em;} li {margin-bottom:5px} code {font-size:16px} blockquote {font-size: 18px} li blockquote {font-size: 16px} <\/style>\n<blockquote><p>This feature is only available in the <a href=\"https:\/\/www.contentviewspro.com\/#buynow\" target=\"_blank\" rel=\"noopener noreferrer\">Pro version<\/a>.<\/p><\/blockquote>\n<blockquote><p>You should not reuse the views that enabled Live Filter, Shuffle Filter. Because these features don&#8217;t support the below parameters.<\/p><\/blockquote>\n<blockquote><p>Replace &#8220;VIEW_ID&#8221; below with ID of the View that you want to reuse.<\/p><\/blockquote>\n<blockquote><p>Since version 4.4.0, you can use this feature to <a href=\"http:\/\/contentviewspro.com\/documentation\/article\/show-related-posts-content-views-pro\/\" target=\"_blank\" rel=\"noopener noreferrer\">show related posts<\/a>, and <a href=\"http:\/\/contentviewspro.com\/documentation\/article\/show-custom-field-meta-field-current-post\/\" target=\"_blank\" rel=\"noopener noreferrer\">show current post&#8217;s data<\/a>.<\/p><\/blockquote>\n<p>Reusing helps you to use an existing view for similar purposes, without creating new views. It saves you a lot of time &amp; effort.<br \/>\nYou can reuse a View by using the View shortcode with extra parameters.<br \/>\nThese are available parameters:<\/p>\n<ul>\n<li id=\"reuse_complex\"><strong>reuse_tax_query<\/strong>: reuse taxonomy settings of the existing View while adding extra parameters (cat, tag, taxonomy, taxonomy2, terms, terms2).For example: You have a view VIEW1 that filters posts IN category A. If you want to show posts IN category A, but NOT IN category B, this shortcode will help:<br \/>\n<code>[pt_view id=\"VIEW1\" reuse_tax_query=1 cat=\"B\" operator=\"NOT IN\"]<\/code><\/li>\n<li><strong>cat<\/strong>: slug, name, ID of categories to filter.For example: you have a category with name &#8220;People&#8221;, slug &#8220;people&#8221;, ID 10.<br \/>\nTo show posts in this category, you can use one of these shortcodes:<br \/>\n<code>[pt_view id=\"VIEW_ID\" cat=\"people\" field=\"slug\"]<\/code><br \/>\n<code>[pt_view id=\"VIEW_ID\" cat=\"People\" field=\"name\"]<\/code><br \/>\n<code>[pt_view id=\"VIEW_ID\" cat=\"10\" field=\"id\"]<\/code><\/li>\n<li><strong>tag<\/strong>: slug, name, ID of tags to filter<br \/>\n<blockquote><p>\/\/ Show 5 posts by tag slugs<br \/>\n<code>[pt_view id=\"VIEW_ID\" tag=\"foo,bar,content\" limit=5]<\/code><br \/>\n\/\/ Show posts by categories &amp; tags<br \/>\n<code>[pt_view id=\"VIEW_ID\" cat=\"cat1,cat2\" tag=\"foo,bar\"]<\/code><\/p><\/blockquote>\n<\/li>\n<li id=\"taxonomy-slug\"><strong>taxonomy<\/strong>: slug of the taxonomy to filter (use <code>taxonomy2<\/code> for the second taxonomy).<br \/>\n<blockquote><p>To find the slug of a taxonomy, please look at the address bar of the browser when you visit the taxonomy page in Admin area:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1179\" src=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy.png\" alt=\"\" width=\"770\" height=\"408\" srcset=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy.png 770w, https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy-300x159.png 300w, https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/Content-Views-Pro-get-slug-of-taxonomy-768x407.png 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p><\/blockquote>\n<\/li>\n<li id=\"term-slug\"><strong>terms<\/strong>: slug, name, ID of taxonomy terms (use <code>terms2<\/code> for terms of the second taxonomy).<br \/>\n<blockquote><p>To find the slug of a term, please open the Category or Tag or Taxonomy page, then find value in the <strong>Slug<\/strong> column.<\/p><\/blockquote>\n<blockquote><p>To use the assigned term of the current post, please use the value &#8220;GET_CURRENT&#8221; (<a href=\"https:\/\/contentviewspro.com\/documentation\/article\/show-related-posts-content-views-pro\/\" target=\"_blank\" rel=\"noopener\">read more<\/a>).<\/p><\/blockquote>\n<blockquote><p>To get the current term in its archive page, please use the value &#8220;GET_CURRENT_TERM&#8221;.<\/p><\/blockquote>\n<\/li>\n<li><strong>field<\/strong>: &#8220;slug&#8221; (default), &#8220;name&#8221;, &#8220;id&#8221;.<br \/>\n<blockquote style=\"margin-top: 15px;\"><p>If you use the name (or ID) of categories, tags, terms for the <code>cat<\/code>, <code>tag<\/code>, <code>terms<\/code> parameter, you must use <code>field=\"name\"<\/code> (or <code>field=\"id\"<\/code>). Otherwise, it will return &#8220;No posts found&#8221;.<\/p><\/blockquote>\n<\/li>\n<li><strong>operator<\/strong>: &#8220;IN&#8221; (default), &#8220;NOT IN&#8221;, &#8220;AND&#8221; (use <code>operator2<\/code> for operator of the second taxonomy).<br \/>\nIN \u2014 show posts which associate with one or more of selected terms<br \/>\nNOT IN \u2014 show posts which do not associate with any of selected terms<br \/>\nAND \u2014 show posts which associate with all of selected terms<\/li>\n<li><strong>relation<\/strong>: &#8220;AND&#8221; (default), &#8220;OR&#8221;.<br \/>\nAND \u2014 show posts which match all settings of all taxonomies<br \/>\nOR \u2014 show posts which match one or more settings of taxonomies<\/li>\n<li><strong>author<\/strong>: ID of authors (since version 3.2)<br \/>\n<code>[pt_view id=\"VIEW_ID\" author=\"10,15\"]<\/code><\/li>\n<li><strong>post_type<\/strong>: Slug of the post type to filter (since version 3.2)<\/li>\n<li><strong>limit<\/strong>: number of posts to show (since version 3.5)<\/li>\n<li><strong>offset<\/strong>: number of posts to skip (since version 3.5)<\/li>\n<li><strong>post_parent<\/strong>: ID of the parent page (since version 3.6.0).<br \/>\nIDs of multiple parent pages, separate by commas (since version 5.3.4).<\/li>\n<li><strong>keyword<\/strong>: keyword to search for (since version 3.9.0)<br \/>\n<code>[pt_view id=\"VIEW_ID\" keyword=\"test\"]<\/code><\/li>\n<li><strong>post_id<\/strong>: list of post IDs to show (since version 3.9.0)<br \/>\n<code>[pt_view id=\"VIEW_ID\" post_id=\"1,2,3\"]<\/code><\/li>\n<li id=\"custom_field\"><strong>custom_field_value<\/strong>: set another values for the selected custom fields in the View.<br \/>\n<blockquote><p>\/\/ Set new value for 1 custom field in the View<br \/>\n<code>[pt_view id=\"VIEW_ID\" custom_field_value=\"NEW_VALUE_HERE\"]<\/code><br \/>\n\/\/ Set new values for multiple custom fields in the View<br \/>\n<code>[pt_view id=\"VIEW_ID\" custom_field_value=\"NEW_VALUE_FOR_FIELD_1,NEW_VALUE_FOR_FIELD_2\"]<\/code><\/p><\/blockquote>\n<p>For example, in VIEW1 you filtered events have custom field <strong>_EventVenueID<\/strong> equals 10. Now you want to filter events have <strong>_EventVenueID<\/strong> equals 20, you can use this shortcode: <code>[pt_view id=\"VIEW1\" custom_field_value=\"20\"]<\/code><\/p>\n<p>&gt;&gt; <strong>It requires that the &#8220;Value To Compare&#8221; field in existing View is <ins>not empty<\/ins>:<\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2790\" src=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/CVP-reuse-custom-field.png\" alt=\"CVP - reuse custom field\" width=\"452\" height=\"177\" srcset=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/CVP-reuse-custom-field.png 452w, https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2014\/08\/CVP-reuse-custom-field-300x117.png 300w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/li>\n<\/ul>\n<hr \/>\n<hr id=\"sample\" \/>\n<h2>Examples<\/h2>\n<blockquote><p>To find value for <code>term, term2<\/code> =&gt; <a href=\"#term-slug\">please check here<\/a>.<\/p><\/blockquote>\n<blockquote><p>To find value for <code>taxonomy, taxonomy2<\/code> =&gt; <a href=\"#taxonomy-slug\">please check here<\/a>.<\/p><\/blockquote>\n<p>\/\/ Show WooCommerce products by Categories<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"product_cat\" terms=\"foo,bar\"]<\/code><\/p>\n<p>\/\/ Show WooCommerce products by Tags<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"product_tag\" terms=\"foo,bar\"]<\/code><\/p>\n<p>\/\/ Show WooCommerce products by Attributes<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"pa_another_attribute\" terms=\"foo,bar\"]<\/code><\/p>\n<hr \/>\n<p>\/\/ Show posts match the filter settings of the VIEW1, but does not have category &#8220;foo&#8221;<br \/>\n<code>[pt_view id=\"VIEW1\" reuse_tax_query=1 taxonomy=\"category\" terms=\"foo\" operator=\"NOT IN\"]<\/code><\/p>\n<p>\/\/ Show posts have category &#8220;foo&#8221; but NOT have category &#8220;bar&#8221;<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"category\" terms=\"foo\" operator=\"IN\" taxonomy2=\"category\" terms2=\"bar\" operator2=\"NOT IN\"]<\/code><\/p>\n<p>\/\/ Show posts have category &#8220;foo&#8221; but NOT have tag &#8220;bar&#8221;<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"category\" terms=\"foo\" operator=\"IN\" taxonomy2=\"post_tag\" terms2=\"bar\" operator2=\"NOT IN\"]<\/code><\/p>\n<p>\/\/ Show posts of multiple tag IDs &amp; posts must have all selected tags<br \/>\n<code>[pt_view id=\"VIEW_ID\" tag=\"1,2,3\" field=\"id\" operator=\"AND\"]<\/code><\/p>\n<hr \/>\n<p>\/\/ Show posts of custom taxonomy<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"testimonial\" terms=\"foo,bar\"]<\/code><\/p>\n<p>\/\/ Show posts IN multiple taxonomies<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"testimonial\" terms=\"foo,bar\" taxonomy2=\"customer\" terms2=\"too,tar\"]<\/code><\/p>\n<p>\/\/ Show posts IN one taxonomy, and NOT IN another taxonomy<br \/>\n<code>[pt_view id=\"VIEW_ID\" taxonomy=\"testimonial\" terms=\"foo,bar\" operator=\"IN\" taxonomy2=\"customer\" terms2=\"too,tar\" operator2=\"NOT IN\"]<\/code><\/p>\n<hr \/>\n<p>Thank you,<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>This feature is only available in the Pro version. You should not reuse the views that enabled Live Filter, Shuffle Filter. Because these features don&#8217;t support the below parameters. Replace &#8220;VIEW_ID&#8221; below with ID of the View that you want to reuse. Since version 4.4.0, you can use this feature to show related posts, and &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/reuse-a-view\/\"> <span class=\"screen-reader-text\">Reuse View shortcode (add parameters)<\/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":[12],"class_list":["post-116","docs","type-docs","status-publish","hentry","doc_category-popular-features","doc_tag-reuse-a-view"],"year_month":"2026-09","word_count":926,"total_views":"6","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":[{"term_name":"reuse a view","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/reuse-a-view\/"}],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/116","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=116"}],"version-history":[{"count":6,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/116\/revisions"}],"predecessor-version":[{"id":5490,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/116\/revisions\/5490"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=116"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}