Skip Navigation

[Resolved] How to only show custom field values that are applied to posts in a search filter

This thread is resolved. Here is a description of the problem and solution.

Problem:
A select custom field lists all countries as options, but only some of these have been applied to posts. When creating a search View how to only include those countries in the filter dropdown which have been assigned to posts.

Solution:
In the Custom Search Settings select "Let me choose settings manually" and then choose "Show only available options for each input".

This support ticket is created 4 years, 11 months ago. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by martinE-4 4 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1245593

I am trying to:
Create a parametric search on my custom field 'country' (not a taxonomy) and the pull-down field is revealing all the countries in the world.
Link to a page where the issue can be seen:
offline sorry local
I expected to see:
Just the countries that were entered in the approximately 200 posts that I have. (maybe half a dozen or so)
Instead I got:
All the countries in the world.

Note:
This is a migration from Drupal to WordPress so the FG migration plugin automatically created a custom field in TYPES for country rather than a taxonomy which probably would have fixed this problem. However, since all my content has been imported from Drupal in this way, I don't know if it would be possible to switch my country custom field to a taxonomy.

Is there any way of just showing the countries that exist in my custom post type entries instead of the entire world?

#1245605

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2019-05-14 at 12.45.03.png

Hi Martin

There is a setting in your View which will limit the options to only those applied to posts, see the screenshot.

In WordPress taxonomies are optimised for queries in a way that custom fields are not, but you are only likely to notice the difference on large sites with thousands of posts being queried.

#1245637

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.