Problem:
So I've got a site that has three separate views on it:
1. Latest 5 posts or podcasts (a custom type I made)
2. Latest 5 posts with the category "executive"
3. Latest 5 podcasts
What I want is this, though:
1. Latest 5 posts or podcasts (a custom type I made)
2. Latest 5 posts with the category "executive," excluding any in View #1
3. Latest 5 podcasts, excluding any in View #1
The mixture of Executive posts, non-Executive posts and podcasts is not known from day to day--it varies.
Solution:
There is a workaround for it, for example:
1) Add below codes in your theme/functions.php:
add_shortcode( 'hide-it', 'hide_it_func');
function hide_it_func($atts)
{
return;
}
It will create a new shortcode [hide-it], we can use it to hide the extra HTML div tag in below view.
2) Create view #4: "view-1-only-ids", with same filters as View #1, but outputs only the post IDs:
a) In section "Loop Output Editor", edit the codes to only one line:
[hide-it][wpv-layout-start][/hide-it][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-item index=1][wpv-post-id][wpv-item index=other],[wpv-post-id]</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>[/wpv-no-items-found][hide-it][wpv-layout-end][/hide-it]
b) in section "Filter and Loop Output Integration Editor", edit the codes to only one line:
So it will output only the post IDs.
3) Edit the view #2 (Latest 5 posts with the category "executive") and view #3 (Latest 5 podcasts, excluding any in View #1), add a filter:
Exclude posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-id/
4) Edit the shortcode of view #2 and view #3 , setup the attribute "ids" as view #4, for example:
[wpv-view name="my-view-name" ids="[wpv-view name="view-1-only-ids"]"]
Then test again.
Relevant Documentation: