Reuse a View

Reusing a View is a useful feature of Content Views Pro. It helps you to save your time & effort by use settings & output of existed View.

These are available parameters:

  • cat: slug, name, id of categories to filter
  • tag: slug, name, id of tags to filter
  • taxonomy: slug of taxonomy to filter (use taxonomy2 for second taxonomy)
  • terms: slug, name, id of taxonomy terms (use terms2 for terms of second taxonomy)
  • field: Valid options are slug (default), name, id
  • operator: Valid options are 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 second taxonomy, since 4.5.0)
  • relation: Valid options are 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: Another 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 parent page (since version 3.6.0)
  • keyword: keyword to search (since version 3.9.0)
  • post_id: list of post IDs (since version 3.9.0)
  • reuse_tax_query: Reuse all taxonomy settings of the View while adding custom filters above (since version 3.6.2). For example: You have a view VIEW1 (to filter posts IN category A). When reusing VIEW1, you want to filter posts IN category A but NOT IN category B. This shortcode will help you to archive it easily:
    [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 all products by custom field _price = 50. Now you want to show all products which have _price = 30, you can use this shortcode:
    [pt_view id="VIEW1" custom_field_value=30]
    The limitation of this parameter is it only works if there is only one selected custom field in View settings.

Here are some examples (“A” is ID of View to reuse)

// 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 limit=5]
[pt_view id="A" author="10,15"]

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

// Show posts of tags slug
[pt_view id="A" tag="foo,bar,content"]

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

// Show posts of multi tags ID & all 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 of categories & tags
[pt_view id="A" cat="cat1,cat2" tag="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"]

Especially, since version 4.4.0, you can use this feature to show related posts, show more information of current post.

Notice: Taxonomy parameter

You should use taxonomy parameter when you want to filter by custom taxonomy. To get the slug of taxonomy, please look at the address bar of the browser when you view that taxonomy in Admin area, for example:

Thank for reading!