Demo (Standard Search)

Search the documentation using this form built with WP Advanced Search!

View the source code

functions.php

<?php function my_search_form() { $args = array(); // Set default WP_Query $args['wp_query'] = array( 'post_type' => array('page', 'field', 'param'), 'orderby' => 'title', 'order' => 'ASC' ); // Configure form fields $args['fields'][] = array( 'type' => 'search', 'placeholder' => 'Enter search terms' ); $args['fields'][] = array( 'type' => 'post_type', 'format' => 'checkbox', 'label' => 'Search by post type', 'default_all' => true, 'values' => array('page' => 'Pages', 'field' => 'Fields', 'param' => 'Parameters') ); $args['fields'][] = array( 'type' => 'orderby', 'format' => 'select', 'label' => 'Order by', 'values' => array('title' => 'Title', 'date' => 'Date Added') ); $args['fields'][] = array( 'type' => 'order', 'format' => 'radio', 'label' => 'Order', 'values' => array('ASC' => 'ASC', 'DESC' => 'DESC'), 'default' => 'ASC' ); $args['fields'][] = array( 'type' => 'posts_per_page', 'format' => 'select', 'label' => 'Results per page', 'values' => array(2=>2, 5=>5, 10=>10), 'default' => 10 ); $args['fields'][] = array( 'type' => 'submit', 'class' => 'button', 'value' => 'Search' ); register_wpas_form('myform'); } add_action('init','my_search_form');

Page Template

<?php get_header(); $search = new WP_Advanced_Search('myform'); ?> <div class="row search-section"> <div id="sidebar" class="large-3 columns"> <?php $search->the_form(); ?> </div> <div class="search-results large-9 columns"> <?php $temp = $wp_query; $wp_query = $search->query(); ?> <h4 class="results-count"> Displaying <?php echo $search->results_range(); ?> of <?php echo $wp_query->found_posts; ?> results </h4> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php $post_type = get_post_type_object($post->post_type); ?> <article> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <p class="info"><strong>Post Type:</strong> <?php echo $post_type->labels->singular_name; ?> &nbsp;&nbsp; <strong>Date added:</strong> <?php the_time('F j, Y'); ?></p> <?php the_excerpt(); ?> </article> <?php endwhile; else : echo '<p>Sorry, no results matched your search.</p>'; endif; $search->pagination(); $wp_query = $temp; wp_reset_query(); ?> </div> </div> <?php get_footer(); ?>

Displaying 21-30 of 82 results

debug_level

Post Type: Parameter    Date added: June 24, 2015

Sets the debug level for the search form. Default is ‘log’, which shows the standard level of debugging information. If set to ‘verbose’, more detailed information will be displayed.

default

Post Type: Parameter    Date added: June 25, 2013

Sets a field’s default value. This parameter should generally only be used for fields where multiple options are available (ie select fields, radio buttons & checkboxes). For fields where only 1 value is possible, use the value parameter instead. default & value should never be used at the same time.

default_all

Post Type: Parameter    Date added: October 21, 2013

Used to pre-select all of a field’s options by default. This parameter may only be used with checkbox & multi-select fields. To pre-select a single value, use default instead.

Demo (AJAX Search)

Post Type: Page    Date added: June 28, 2015

This is a demo of a search form configured to use AJAX.

Demo (Results on Separate Page)

Post Type: Page    Date added: June 28, 2015

This demo shows how to configure a search form which when submitted takes users to a separate page to display results. Note that this approach requires setting up a second template (namely, the template in which to display your search results). View the source code functions.php Page Template

Demo (Standard Search)

Post Type: Page    Date added: June 24, 2013

Search the documentation using this form built with WP Advanced Search!

Demos

Post Type: Page    Date added: June 28, 2015

Here you can find demos of various implementations of WP Advanced Search, along with the source code needed to create them. Standard Search AJAX Search Showing Results On Separate Page

disable_wrappers

Post Type: Parameter    Date added: June 28, 2015

When set to true, this parameter will turn off HTML wrappers for all search fields. By default, all form fields generated by WPAS are wrapped in an outer div element. In some cases you may want to disable these wrappers to allow for further customization of your form’s layout.

Documentation

Post Type: Page    Date added: February 26, 2013