Forums › Forums › Search & Filter Pro › Combine a keyword search with user’s choice of custom field values
Tagged: acf, checkboxes, custom field
- This topic has 21 replies, 2 voices, and was last updated 4 years, 3 months ago by Trevor.
-
Anonymous(Private) July 28, 2020 at 8:28 pm #254232
Hi
I have a custom post type ‘xxxxxx’
– each post has several ACF fields for displaying dataThe form and the initial view (of all XXXXX items) is set up on a custom template page
The results go to the default search.php
– where I separate out the XXXXX results from all other site’s resultsThis works fine
——————
I have now added a new ACF field ‘yyyyy-choice’
– each xxxxxx cpt will have one of 10 choices
choice one
choice two
choice three
… etc…I now need to change this landing page to have a search/filter tool to combine two tasks.
The visitor needs to find an item by keyword search from within a chosen selection of values from yyyyy-choice
Possibly as a set of checkboxes underneath the main keyword search field
– each checkbox represents one of the 10 values within yyyyy-choice
– with a submit after this?——————
I would like search.php to then display all xxxx items that match those yyyyy-choice values
i.e.
search for ‘alexander’ within choice one … show 5 items
or
search for ‘alexander’ within choice one and choice four … show 10 itemsI have your Search & Filter Pro plugin
– but I can’t seem to get this set up?If you could point me to a demo or information that I can work through
Trevor(Private) July 29, 2020 at 9:18 am #254272So, I expect to see a search form with the search text box and the options for that field, plus maybe a submit button. If this is a Post Meta field, I would expect it to be set like this:
https://www.screencast.com/t/EqZ7jI4m
Notice the Search Operator set to OR.
If this does not work, are you able to send me a live link/URL to your search page so I can take a look?
Trevor(Private) July 29, 2020 at 12:07 pm #254332I see the error. In selecting the Meta Key name, note a ‘gotcha’ with ACF ….
… it makes 3 meta keys per field, like this (in this example for a field named ‘land’):
#1
_land
#2field_52f0fc4334f52
#3land
In our Meta Key selection list, you need to use key #3, without the underscore at the start of the key name. If you choose #1 by mistake, in the field choices you will see the name of #2.
-
AuthorPosts