Skip Navigation

[Resolved] I want to filter previous results from other views on the same page

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Noman 6 years, 10 months ago.

Assisted by: Noman.

Author
Posts
#545421

I am trying to: use multiple views on the same page. Each of the views are different categories. I would like to have an final view exclude any of the results which have already appeared in the other views. Is this possible or do I need to come up with my own solution?

I visited this URL:

I expected to see:

Instead, I got:

#545517

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Darcy,

Thank you for contacting Toolset support.

1. “To have an final view exclude any of the results which have already appeared in the other views.”
Can you please more clarify this? Is this the search view which displays the results?

2. What you expected to see on the front page?
3. What you actually see right now? (preferably with frontend link or screenshot)

Looking forward to help you.
Than you

#545549

If I have three views on one page.

View 1 displays posts 1, 2 and 3
View 2 displays posts 4, 5, and 6
View 3 should automatically excluded posts 1,2,3,4,5 and 6 from it's results.

#545588

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Okay, then what to display in View 3?

Can you please provide back-end screenshot of View 3?

Can you please provide link to page where you displayed the three views?

#545635

Anything, everything, except those posts which have already been displayed in Views 1 and 2.

I need to be able to keep track of posts that have already been displayed and exclude them from other views so I do not have duplicate content on the same page.

#545707

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

1. Offset.png
2. Exclude.png

There are 2 ways you can exclude posts from a View:
1. Using Offset settings, screenshot attached.
2. Using Query Filter >> Post ID filter, screenshot attached.

If you want to exclude posts dynamically, for example like this:
- if some posts are shown in 1st view.
- then those should be automatically Excluded from the 2nd view.
- then posts shown in 1st and 2nd view should be automatically Excluded from 3rd view.

If you are looking to do it like the above dynamic scenario, then this won’t be possible and we do not have any builtin options to track and exclude it in this way. You would need to create a Custom Shortcode for this purpose. We have some recommended list of service providers here who can help in such cases for you: https://toolset.com/consultant/

Thank you

#545848

Is there any documentation on how to construct a custom shortcode. I know how to create shortcodes and I am confortable working in PHP. I am less familiar with working within Toolset. Do I need to establish a variable in the loop that is collecting each of the post_ids or do I need to hook off of the actual query and collect those that way. If I do the latter, how do I access the values from those shortcodes? Is this done via a URL parameter? Is it possible within a shortcode function (in PHP) to propogate a variable that would be accessible within a view? Are variables just part of PHP global space?

#546026

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello,

Views offer various API hooks which you can use to modify results through code:
https://toolset.com/documentation/programmer-reference/views-filters/
- For your case wpv_filter_query hook might be useful. On the above page there are example php codes given for each hook as well, so you can see how View can be modified.

- For the shortcode you will create it just as standard WP shortcode: https://codex.wordpress.org/Shortcode_API
- Shortcode Example: https://toolset.com/forums/topic/conditional-display-based-on-user-role-of-post-author/#post-543582

More info:
https://toolset.com/documentation/programmer-reference/views-api/
https://toolset.com/documentation/user-guides/shortcodes-within-shortcodes/

Thank you

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.