Reuse a View

This feature is only available in the Pro version.

Reusing a View is a useful feature of Content Views Pro. It saves your time & effort by using the settings & output of existing Views for a new purpose.
Reusing a View uses the View shortcode with extra parameters.
These are available parameters:

  • cat: Slug, Name, ID of categories to filter
  • tag: Slug, Name, ID of tags to filter
  • taxonomy: Slug of the taxonomy to filter (use taxonomy2 for the second taxonomy).
    To get the slug of 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)
  • field: “slug” (default), “name”, “id”.

    If you use the name (or ID) of categories, tags, terms for the cat, tag, terms parameter, you must use field="name" (or field="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
    (use operator2 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)
  • 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)
  • post_id: list of post IDs to show (since version 3.9.0)
  • 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 value for the selected custom field in View (since version 4.3.0).
    For example, in VIEW1 you are filtering events by the custom field _EventVenueID = 10. Now you want to show events which have _EventVenueID = 20, you can use this shortcode: [pt_view id="VIEW1" custom_field_value=20]

    It only works if there is only one selected custom field in the existing View:
    CVP - reuse custom field

    It will NOT work if value of the “Value To Compare” setting is empty.

Examples

In below examples, “A” is the ID of the reused View.

// Show posts by IDs
[pt_view id="A" post_id="1,2,3"]

// Show posts which contain keyword
[pt_view id="A" keyword="test"]

// Show posts by author IDs
[pt_view id="A" author="10,15"]

// Show products
[pt_view id="A" post_type=product]

// Show posts of category IDs
[pt_view id="A" cat="1,2,3" field="id"]

// Show 5 posts of tag slugs
[pt_view id="A" tag="foo,bar,content" limit=5]

// Show posts of categories & tags
[pt_view id="A" cat="cat1,cat2" tag="foo,bar"]

// Show posts have category “foo” but NOT have category “bar”
[pt_view id="A" taxonomy=category terms="foo" operator="IN" taxonomy2=category terms2="bar" operator2="NOT IN"]

// Show posts have tag “foo” but NOT have tag “bar”
[pt_view id="A" taxonomy=post_tag 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="A" tag="1,2,3" field="id" operator=AND]

// Show posts of custom taxonomy
[pt_view id="A" taxonomy=testimonial terms="foo,bar"]

// Show posts IN multiple taxonomies
[pt_view id="A" taxonomy=testimonial terms="foo,bar" taxonomy2=customer terms2="too,tar"]

// Show posts IN one taxonomy, and NOT IN another taxonomy
[pt_view id="A" taxonomy=testimonial terms="foo,bar" operator=IN taxonomy2=customer terms2="too,tar" operator2="NOT IN"]


Since version 4.4.0, you can use this feature to show related posts, and show current post’s data.

Thank you,