Problem: I have a nested View structure that loops over post type A in a M2M relationship, and displays all the post type B related posts for each item in the loop of post type A. Since it's an M2M relationship, some post type B are shown multiple times. I would like to filter out the duplicate posts.
Solution: There is not an easy way to do this with nested Views. A JavaScript solution can work, but only without pagination in the View. In the Loop Editor:
<wpv-loop> <div class="remove-duplicate-stories"> [wpv-post-link] </div> </wpv-loop>
In the JavaScript panel:
jQuery(document).ready(function(){ var seen = {}; jQuery('.remove-duplicate-stories').each(function() { var txt = jQuery(this).text(); if (seen[txt]) jQuery(this).remove(); else seen[txt] = true; }); });
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 4 months ago.
Assisted by: Christian Cox.