Navigation überspringen

[Gelöst] Split: How to remove duplicated results

This support ticket is created vor 3 Jahren, 8 Monaten. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

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

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von davidm-13 vor 3 Jahren, 8 Monaten.

Assistiert von: Waqar.

Author
Artikel
#2029259

Hi Waqar,
Have another problem I need each result to be unique and not repeat in results list, how do I change the search to achieve this?
Thanks

#2029279

Hi,

The duplicate results are showing because, the view is for the child post type, whereas the post link in the results is shown for the posts from the parent post type.

To overcome this you can follow these steps:

1. In your view's output, you'll include a class "result-items" to the ul tag that wraps the results:


<ul style="width:20vw; height:30vh; overflow:auto; padding:5px; list-style-type: none; margin-left: 20vw" class="result-items">

2. Also, to make them identifiable, you'll include a special class with the post ID, to the li tag that wraps the post link :


<li class="result-item-[wpv-post-id item='@plant-complaint.parent']"> [wpv-post-link item="@plant-complaint.parent"] </li>

3. The following script will be needed in the view's "JS editor" which can hide all the results items where the parent post ID is the same, except for the first instance:


jQuery(document).ready(function(){
	jQuery('ul.result-items li').each(function() {
		var classNames = jQuery(this).attr("class");
		jQuery('li.'+classNames).not(':first').hide();
	});
});

I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#2029421

My issue is resolved now. Thank you!