Fields
Fields can be added to your search form by creating & extending the ‘fields’ key of your arguments array. Each value in the ‘fields’ array contains an array storing arguments for that field. Fields will be generated on the page in the order they are defined.
$args = array (); $args [ 'wp_query' ] = array ( 'post_type' => 'post' , 'posts_per_page' => 5); $args [ 'fields' ][] = array ( 'type' => 'search' ); $args [ 'fields' ][] = array ( 'type' => 'author' ); $args [ 'fields' ][] = array ( 'type' => 'taxonomy' ); ... register_wpas_form( 'myform' , $args ); |
Field Types
There are a variety of field types available for use in your search forms. They are:
- author
- clear
- date
- generic
- html
- meta_key
- order
- orderby
- posts_per_page
- post_type
- reset
- search
- submit
- taxonomy
Example: Creating a taxonomy field
$args [ 'fields' ][] = array ( 'type' => 'taxonomy' ); |
Field Formats
Fields can be constructed in a variety of formats, such as: text inputs, select boxes, checkboxes, radio buttons, and multi-select. You can specify a field’s format by passing a ‘format’ parameter to the field’s arguments:
$args [ 'fields' ][] = array ( 'type' => 'taxonomy' , 'format' => 'select' ); |
The above code will create a taxonomy field as a select box. For more information, consult the documentation on field formats & parameters.
- Configuration
- Fields
- search
- taxonomy
- meta_key
- date
- post_type
- order
- orderby
- author
- posts_per_page
- generic
- html
- submit
- clear
- reset
- Field Parameters
- Template Setup
- Plugins