[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.
- action – Determines form behavior.
- Default:
redirect. - Options:
redirect,open_modal. Specify one only.
- Default:
- pageid – WordPress page ID to redirect.
- Options: Any numeric value. Specify one only.
- modal – Modal ID to open.
- Options: Any numeric value. Specify one only.
- button_label – Text for the submit button.
- Default:
Search. - Options: Any text value.
- Default:
- widget – Whether to wrap the form in a widget container.
- Default:
off. - Options:
on,off. Specify one only.
- Default:
- widget_title – Title to display when using widget mode on the sidebar.
- Options: Any text value.
- widget_class – Additional CSS class for the widget container.
- Options: Any text value.
- active – Whether the form should be rendered.
- Default:
on. - Options:
on,off. Specify one only.
- Default:
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. |
When using widget mode, additional styling classes can be applied to the container.