Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate items appear in rendered field (Admin User-facing) #4

Open
incredimike opened this issue Jul 2, 2017 · 0 comments
Open

Comments

@incredimike
Copy link

I've spent some time debugging this issue. I've discovered that when you have multiple taxonomies with one-or-more terms that share the same "name" (or title or label or whatever), the rendered Taxonomy Term picker will erroneously show the "term options" for each same-named term in each optgroup.

Clear as mud? This is the configuration:

Select Type = Term
Output type = ID

Also assume I have the following taxonomies & terms in a WP site:

Taxonomy: Category
Term: travel
Term: nightlife
Term: other

Taxonomy: Sizes
Term: small
Term: medium
Term: large
Term: other

In file acf-taxonomy-chooser-v5.php around line 312 you loop over all terms in wordpress. For each term you check if it's "name" matches a list of Admin-selected terms. If so, add it to the list. But since you're looping over ALL terms, you will end adding "other" twice, since it gets checked twice (and the check passes both times).

The plugin should find the IDs of the terms some other way. Probably build a look-up array earlier in the function that simply maps the ACF "parent-tax-slug:term-slug" to the ID. I might just do that and submit a pull request.

You also do a regex on line 308 to strip out a beginning "-" character with any space. I'm not sure this makes sense, since category names don't actually have a hyphen before them? Unless I'm missing something. Anyway, the way the regex is written, it removes all dashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant