This feature is only available in the Pro version.
Notice: You should not reuse the views that enabled Live Filter, Shuffle Filter. Because these features don’t support the below parameters.
In below examples, “VIEW_ID” is the ID of the reused View.
Reusing a View helps you to use the existing Views for a new purpose, without creating new views. It saves you a lot of time & effort.
You reuse a View by using the View shortcode with extra parameters.
These are available parameters:
- cat: slug, name, ID of categories to filter.
For example: you have a category with name “People”, slug “people”, ID 10.
To show posts in this category, you can use one of these shortcodes:
[pt_view id="VIEW_ID" cat="people" field="slug"]
[pt_view id="VIEW_ID" cat="People" field="name"]
[pt_view id="VIEW_ID" cat="10" field="id"]
- tag: slug, name, ID of tags to filter
// Show 5 posts by tag slugs
[pt_view id="VIEW_ID" tag="foo,bar,content" limit=5]
// Show posts by categories & tags
[pt_view id="VIEW_ID" cat="cat1,cat2" tag="foo,bar"]
- taxonomy: Slug of the taxonomy to filter (use
taxonomy2
for the second taxonomy).
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:
- terms: slug, name, ID of taxonomy terms (use
terms2
for terms of the second taxonomy).
To find the slug of a term, please open the Category or Tag or Taxonomy page, then find value in the Slug column.
- field: “slug” (default), “name”, “id”.
If you use the name (or ID) of categories, tags, terms for the
cat
,tag
,terms
parameter, you must usefield="name"
(orfield="id"
). Otherwise, it will return “No posts found”. - operator: “IN” (default), “NOT IN”, “AND”.
IN — show posts which associate with one or more of selected terms
NOT IN — show posts which do not associate with any of selected terms
AND — show posts which associate with all of selected terms
(useoperator2
for operator of the second taxonomy, since 4.5.0) - relation: “AND” (default), “OR”.
AND — show posts which match all settings of all taxonomies
OR — show posts which match one or more settings of taxonomies - author: ID of authors (since version 3.2)
[pt_view id="VIEW_ID" author="10,15"]
- post_type: Slug of the post type to filter (since version 3.2)
- limit: number of posts to show (since version 3.5)
- offset: number of posts to skip (since version 3.5)
- post_parent: ID of the parent page (since version 3.6.0).
IDs of multiple parent pages, separate by commas (since version 5.3.4). - keyword: keyword to search for (since version 3.9.0)
[pt_view id="VIEW_ID" keyword="test"]
- post_id: list of post IDs to show (since version 3.9.0)
[pt_view id="VIEW_ID" post_id="1,2,3"]
- reuse_tax_query: Reuse all taxonomy settings of the existing View while adding custom filters above (since version 3.6.2).
For example: You have a view VIEW1 (to filter posts IN category A). If you want to filter posts IN category A but NOT IN category B, this shortcode will help:
[pt_view id="VIEW1" reuse_tax_query=1 cat="B" operator="NOT IN"]
- custom_field_value: set another values for the selected custom fields in View.
For example, in VIEW1 you filtered events have custom field _EventVenueID equals 10. Now you want to filter events have _EventVenueID equals 20, you can use this shortcode:[pt_view id="VIEW1" custom_field_value="20"]
To setting values for multiple custom fields in the View, please use comma as separator, for example:
[pt_view id="VIEW1" custom_field_value="VALUE_FOR_FIELD_1,VALUE_FOR_FIELD_2"]
It requires that the “Value To Compare” field in existing View is not empty:
Examples
To find value for
term, term2
=> please check here.
To find value for
taxonomy, taxonomy2
=> please check here.
Since version 4.4.0, you can use this feature to show related posts, and show current post’s data.
// Show WooCommerce products by Categories
[pt_view id="VIEW_ID" taxonomy="product_cat" terms="foo,bar"]
// Show WooCommerce products by Tags
[pt_view id="VIEW_ID" taxonomy="product_tag" terms="foo,bar"]
// Show WooCommerce products by Attributes
[pt_view id="VIEW_ID" taxonomy="pa_another_attribute" terms="foo,bar"]
// Show posts match the filter settings of the VIEW1, but does not have category “foo”
[pt_view id="VIEW1" reuse_tax_query=1 taxonomy="category" terms="foo" operator="NOT IN"]
// Show posts have category “foo” but NOT have category “bar”
[pt_view id="VIEW_ID" taxonomy="category" terms="foo" operator="IN" taxonomy2="category" terms2="bar" operator2="NOT IN"]
// Show posts have category “foo” but NOT have tag “bar”
[pt_view id="VIEW_ID" taxonomy="category" terms="foo" operator="IN" taxonomy2="post_tag" terms2="bar" operator2="NOT IN"]
// Show posts of multiple tag IDs & posts must have all selected tags
[pt_view id="VIEW_ID" tag="1,2,3" field="id" operator="AND"]
// Show posts of custom taxonomy
[pt_view id="VIEW_ID" taxonomy="testimonial" terms="foo,bar"]
// Show posts IN multiple taxonomies
[pt_view id="VIEW_ID" taxonomy="testimonial" terms="foo,bar" taxonomy2="customer" terms2="too,tar"]
// Show posts IN one taxonomy, and NOT IN another taxonomy
[pt_view id="VIEW_ID" taxonomy="testimonial" terms="foo,bar" operator="IN" taxonomy2="customer" terms2="too,tar" operator2="NOT IN"]
Thank you,