[search_form_field]
The shortcode generates a search form field that can be used in [search_form] to create customizable search filters. It supports multiple field types including text inputs, select dropdowns, radio buttons, checkboxes, and button groups.
Product
Shortcode Attributes
There are a number of shortcode attributes available which you can use to customize the output.
General
- name – The name attribute for the form field.
- Default:
s. - Options: Any text value.
- Default:
- label – Label text displayed above the field.
- Options: Any text value.
- placeholder – Placeholder text for input fields.
- Default:
Search. - Options: Any text value.
- Default:
- type – Field type.
- Default:
text. - Options:
text,select,radio,checkbox,button. Specify one only.
- Default:
- disabled – Whether the field should be disabled.
- Default:
0. - Options:
0,1. Specify one only.
- Default:
- classes – Additional CSS classes for the field.
- Options: Any text value.
Choice-related
For taxonomy based:
- choices_source – Source of options. Use taxonomy.
- Options:
custom,taxonomy,option_field,post.
- Options:
- choices – WordPress taxonomy slug.
- Default:
category. - Options: Any text value. Specify one only.
- Default:
- populate – Whether to enable dynamic population (for hierarchical data).
- Default:
0. - Options:
0,1. Specify one only.
- Default:
- include_children – Whether to include child terms in taxonomy options.
- Default:
0. - Options:
0,1. Specify one only.
- Default:
- child_level – Depth level for child terms inclusion. Requires include_children to be on.
- Default:
1. - Options: Any numeric value. Specify one only. Note: if start on 1, the main parent term below 1 will not be included.
- Default:
- parameter – Parent parameter name for dependent fields. Requires both include_children and populate to be on, the populate field must also be on a lower level than the source field.
- Options: Any text value. Specify one only.
For option field:
- choices_source – Source of options. Use option_field.
- Options:
custom,taxonomy,option_field,post.
- Options:
- choices – Used to define the option field to get choices from. Accepts Repeater.
- Options: Repeater Option field formatted value (
repeater_field_name:sub_field_name).- Example:
product_file_type_options:file_type.
- Example:
- Options: Repeater Option field formatted value (
For post:
- choices_source – Source of options. Use post.
- Options:
custom,taxonomy,option_field,post.
- Options:
- choices – WordPress post type / custom post type. Used to specify the post type where the post field choices will get from.
- Options: Any text value.
For custom:
- choices_source – Source of options. Use post.
- Default:
custom. - Options:
custom,taxonomy,option_field,post. Specify one only.
- Default:
- choices – Used to define the custom search filter choices
- Options:
selector : value formatted value. Use commas,to separate.- Example:
.red : Red.
- Example:
- Options:
Example Usage
[search_form pageid=101]
[search_form_field name=”categories” type=”select” choices_source=”taxonomy” choices=”product_cat” placeholder=”Categories”]
[search_form_field name=”sub_categories” type=”select” choices_source=”taxonomy” choices=”product_cat” placeholder=”Sub Categories” include_children=”on” populate=”on” parameter=”categories”]
[/search_form]
Results
| Example: This example displays a search form with two dependent dropdown select fields: 1. A “Categories” dropdown populated with top-level terms from the product_cat taxonomy.2. A “Sub Categories” dropdown that dynamically populates with child terms based on the selected parent category. The populate="on" and parameter="categories" attributes enable the dependency between the two fields. |