[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

  1. name – The name attribute for the form field.
    • Default: s.
    • Options: Any text value.
  2. label – Label text displayed above the field.
    • Options: Any text value.
  3. placeholder – Placeholder text for input fields.
    • Default: Search.
    • Options: Any text value.
  4. type – Field type.
    • Default: text.
    • Options: text, select, radio, checkbox, button. Specify one only.
  5. disabled – Whether the field should be disabled.
    • Default: 0.
    • Options: 0, 1. Specify one only.
  6. classes – Additional CSS classes for the field.
    • Options: Any text value.

Choice-related

For taxonomy based:

  1. choices_source – Source of options. Use taxonomy.
    • Options: custom, taxonomy, option_field, post.
  2. choices – WordPress taxonomy slug.
    • Default: category.
    • Options: Any text value. Specify one only.
  3. populate – Whether to enable dynamic population (for hierarchical data).
    • Default: 0.
    • Options: 0, 1. Specify one only.
  4. include_children – Whether to include child terms in taxonomy options.
    • Default: 0.
    • Options: 0, 1. Specify one only.
  5. 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.
  6. 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:

  1. choices_source – Source of options. Use option_field.
    • Options: custom, taxonomy, option_field, post.
  2. 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.

For post:

  1. choices_source – Source of options. Use post.
    • Options: custom, taxonomy, option_field, post.
  2. 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:

  1. choices_source – Source of options. Use post.
    • Default: custom.
    • Options: custom, taxonomy, option_field, post. Specify one only.
  2. choices – Used to define the custom search filter choices
    • Options: selector : value formatted value. Use commas , to separate.
      • Example: .red : Red.

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.
Populated taxonomy-based search form fields are too advanced and rarely used. This is not handled on the back end, so overriding the element template might be necessary to add a request handler for the additional populated fields.