Пример #1
0
function my_search_form()
{
    $args = array();
    $args['form'] = array('action' => site_url('index.php/search-page'), 'method' => 'GET');
    #$args['wp_query'] = array('post_type' => 'post', 'posts_per_page' => 5);
    $args['wp_query'] = array('post_type' => 'post', 'posts_per_page' => 9, 'order' => 'DESC', 'orderby' => 'date');
    $args['fields'][] = array('type' => 'search', 'title' => 'Search Projects', 'class' => 'form-control');
    $args['fields'][] = array('type' => 'submit', 'value' => 'Search', 'class' => 'btn btn-primary');
    register_wpas_form('my-form', $args);
}
Пример #2
0
function wp_ajax_search()
{
    $args = array();
    $args['wp_query'] = array('post_type' => 'project', 'posts_per_page' => 6);
    $args['form'] = array('auto_submit' => false);
    $args['form']['ajax'] = array('enabled' => true, 'show_default_results' => false, 'results_template' => 'template-ajax-results.php', 'button_text' => 'Load More Results');
    $args['fields'][] = array('type' => 'search', 'placeholder' => 'Enter search terms');
    $args['fields'][] = array('type' => 'taxonomy', 'taxonomy' => 'projecttype', 'format' => 'select');
    $args['fields'][] = array('type' => 'meta_key', 'meta_key' => 'project_single_sqft', 'placeholder' => 'SQFT', 'format' => 'text', 'compare' => '>=', 'data_type' => 'NUMERIC');
    $args['fields'][] = array('type' => 'meta_key', 'meta_key' => 'project_single_bedrooms', 'placeholder' => '# of Bedrooms', 'format' => 'text', 'compare' => '>=', 'data_type' => 'NUMERIC');
    $args['fields'][] = array('type' => 'meta_key', 'meta_key' => 'project_single_bathrooms', 'placeholder' => '# of  Bathrooms', 'format' => 'text', 'compare' => '>=', 'data_type' => 'NUMERIC');
    $args['fields'][] = array('type' => 'submit', 'class' => 'button', 'value' => 'Search');
    register_wpas_form('my-form', $args);
}
Пример #3
0
<?php

add_action("init", function () {
    $form_id = "default";
    $args = array();
    $args['wp_query'] = array('post_type' => array('post'), 'posts_per_page' => 10);
    $args['config']['meta_key_relation'] = 'AND';
    $args['config']['taxonomy_relation'] = 'AND';
    $args['fields'][] = array('type' => 'search', 'label' => 'Search');
    $args['fields'][] = array('type' => 'taxonomy', 'label' => 'Category', 'taxonomy' => 'category', 'format' => 'select', 'allow_null' => true, 'operator' => 'AND');
    $args['fields'][] = array('type' => 'submit', 'value' => 'Submit');
    register_wpas_form($form_id, $args);
});