Matthias Reichl
In den letzten 30 Tagen erstellte Support-Threads: 0
Lieblings-Forenthemen
This user has no favorite topics.
Forum Topics Created
Status | Thema | Supporter | Stimmen | Artikel | Aktualität |
---|---|---|---|---|---|
Exclude duplicate entries in a view
Gestartet von: Matthias Reichl
in: Toolset Professional Support
Problem: I have a View that shows a list of posts in a custom post type. Some of my posts have the same title. I would like to remove the duplicate titles from the View. How can I filter by unique post title? Solution: There is no simple way to filter duplicate titles from wp-admin. You could implement your own custom code that uses the wpv_filter_query API or the wpv_filter_query_post_process API to filter out matching titles, or you can use this jQuery snippet to hide them on the frontend: jQuery(document).ready(function(){ var strs = []; var dupes = []; jQuery('.wpv-loop').find('li > a').each(function(index,item){ var txt = jQuery(item).text(); if( strs.indexOf(txt) > -1 ) { dupes.push(index); } else{ strs.push(txt); } }); dupes.reverse(); for(var i=0; i<dupes.length; i++) { jQuery('.wpv-loop').find('li').eq(dupes[i]).remove(); } }); Note that the duplicates may appear momentarily on the front-end until the JavaScript has been executed. Relevant Documentation: |
2 | 5 | vor 6 Jahren, 10 Monaten |