I have a custom search set up with a select item as 1 of the filters. It displays a list of a field. Some of the items are listed twice and also out of Alpha order. Here is a link to the page with the view: hidden link
Can anyone help with why this is happening.
Hi, I'll be glad to take a look. First, can you try these quick troubleshooting steps?
- Please ensure your WordPress, Toolset plugins, and Theme are all up-to-date. Make a backup of your site before any updates.
- Temporarily disable any non-Toolset plugins, and activate a default theme like Twenty Seventeen. Is the problem resolved?
- Please share a screenshot of any Query Filter settings for this View, as well as a screenshot of your Filter Controls.
All WordPress and Toolset plugins are up to date. Unfortunately, I am not able to change the theme to test or disable other plug ins at this time.
I have attached a screen shot of the Filter editor window for this view.
Okay I understand that it's not always practical to make changes to a live site. Instead, I would like to create a clone of your site so I can investigate further without causing any problems. In order to do this, I would like to install the Duplicator plugin: https://wordpress.org/plugins/duplicator/
If that's okay with you, please provide login credentials to your site here in the private reply fields enabled with your next reply. I will create the site clone, then install it on my local environment to run additional tests. I will remove the plugin and the clone it creates from your site when I'm done.
Please let me know if you approve, and I will proceed. Thanks!
Okay let's try a few other things if you cannot provide a clone or access.
- Look in your custom field settings for the 2author-names field. Do any duplicates appear in the options list here?
- Count the number of options available for your field. How does this number compare to the number of options shown in the select box? Are any options missing?
- How is the 2author-names field set up - is this a multiselect, or multiple checkboxes, or a repeating field? Please share any details you can about this field.
- Do you have access to your site's theme files? If so, can you find any custom code that may be modifying these options using the Types API or WordPress API?
Answers bellow questions
- Look in your custom field settings for the 2author-names field. Do any duplicates appear in the options list here?
No there are no duplicates. I have attached a screen grab of the post fields for this post type.
- Count the number of options available for your field. How does this number compare to the number of options shown in the select box? Are any options missing?
The same. Attached is a screen grab of the fields list in one of the pages for this post type.
- How is the 2author-names field set up - is this a multiselect, or multiple checkboxes, or a repeating field? Please share any details you can about this field.
Multiple line with Allow Multiple Instances checked. Attached is a screen grab of the settings for this field
- Do you have access to your site's theme files? If so, can you find any custom code that may be modifying these options using the Types API or WordPress API?
The Types and WordPress API's have not been altered.
Ok thanks, I understand now. The multiple-instance, multiple-line input is at the root of this problem. This input type isn't designed to prevent duplicate entries. Let's say two publications are authored by John Doe. If multiple separate publications include 2author_name "Doe, John", then "Doe, John" will appear multiple times in your list. That's because each item that gets entered here is stored separately in the database, and there is no validation to prevent duplicates. Therefore no two publications can ever have the same author. Their authors only have the same name, if that makes sense.
To make this work as you expect it to work, you must use a different input type. You could use a checkbox group or a multiselect, but either way the options must be predefined.
Another approach would be to use a custom author taxonomy. Then you can use the taxonomy interface to manage authors for each publication. This interface includes a typeahead combined with the ability to add new authors easily, so you wouldn't have these duplicate results.
Let me know if I can provide additional assistance here.
Thank you, I understand your suggestions.
I am wondering why this is a seemingly intermittent issue ? For instance, there are many articles authored by Bruce Greyson and his name only appears once in the list -- where as Jim Tucker has authored not as many and his name appears more than once ?
Also, I was wondering if there is any way to sort a check box field by last name -- so if I set up a post field as multiple check boxes with an author name listed as Bruce Greyson, another as Ian Stevenson, etc... can those be sorted by last name automatically ?
Hmmm, I must admit that I misunderstood how repeating multiline fields work with search. After some additional tests on my end, I can see that duplicates aren't created when you add authors with the same name. Instead, the only way I can create duplicates in my list is if the author name includes a carriage return after the text. So even though the names are spelled the same, the spacing and line breaks are different. In this case, these two entries will appear as duplicates. So apologies if I misled you there, I stand corrected. The easiest fix would be to go through all the posts and ensure there are no extra carriage returns after the author's name.
To answer your other question, if you do decide to go with checkboxes, you can reorder the options by drag and drop within the custom field editor.