views:

225

answers:

4

Hello everybody,

I'm using this codes for listing custom field values into drop-down list element on this category in Wordpress (screenshot is here what i'm point out).

So there are duplicate items on drop-down list and how i can delete duplicate entries on list?

Thanks in advance.

A: 

Your best bet is to check for duplicates before you print them to the list. If they are always sorted (as it appears in your example), then you can easily do this just by keeping track of what was the last value you used. Make sure the current value does not match, then display it and assign it as the new last value.

JGB146
A: 

Check here: http://www.martienus.com/code/javascript-remove-duplicates-from-array.html

or google 'delete duplicates javascript' or some such.

So basically, read everything in the dropdown into an array, delete everything in the dropdown, de-dupe the array, and add the results into the dropdown for the quick and dirty...

I'm sure you could come back later and do it all by only deleting things from the dropdown without deleteing everything else and adding them back as an exercise in efficiency later.

George Sisco
No, i'm searching PHP based solution not JS.
fatihturan
A: 

Remove duplicate custom fields: WordPress › Custom Field Taxonomies « WordPress Plugins

songdogtech
A: 

I found a solution from an IRC person (alxndr). This example is solved my problem.

fatihturan