[search_form]

The shortcode provides a flexible search form that can be used in various contexts, including as a widget or inline form. It supports two primary actions: redirecting to a search results page or opening a modal window.


Product


Shortcode Attributes

There are a number of shortcode attributes available which you can use to customize the output.

  1. action – Determines form behavior.
    • Default: redirect.
    • Options: redirect, open_modal. Specify one only.
  2. pageid – WordPress page ID to redirect.
    • Options: Any numeric value. Specify one only.
  3. modal – Modal ID to open.
    • Options: Any numeric value. Specify one only.
  4. button_label – Text for the submit button.
    • Default: Search.
    • Options: Any text value.
  5. widget – Whether to wrap the form in a widget container.
    • Default: off.
    • Options: on, off. Specify one only.
  6. widget_title – Title to display when using widget mode on the sidebar.
    • Options: Any text value.
  7. widget_class – Additional CSS class for the widget container.
    • Options: Any text value.
  8. active – Whether the form should be rendered.
    • Default: on.
    • Options: on, off. Specify one only.

Shortcode Enclosed Content

Any content placed between [search_form] and [/search_form] will be used as a template, allowing the inclusion of any text, as well as the [search_form_field] and [address_lookup_form_field] shortcodes for defining form fields.


Example Usage

[search_form widget="1" widget_title="Project Search" action="redirect" pageid="456"]
   [search_form_field name="name" type="text" placeholder="Title"]
   [search_form_field name="categories" type="select" choices_source="taxonomy" choices="project_cat" placeholder="Categories"]
[/search_form]

Results

Example:
This example displays a widget-style search form titled “Project Search” with a text field for title filtering and a category dropdown, which redirects to page ID 456 upon submission.
The shortcode expects inner content (fields) to be passed between the opening and closing tags.
When using widget mode, additional styling classes can be applied to the container.