/** * Constructs JSON-formatted response object for AJAX requests * * @param array $post * @return mixed|string|void */ function wpas_build_ajax_response(array $post) { $request = array(); if (isset($post['form_data'])) { parse_str($post['form_data'], $request); } $page = isset($post['page']) ? $post['page'] : 0; $request['paged'] = $page; $wpas_id = $request['wpas_id']; $wpas = new WP_Advanced_Search($wpas_id, $request); $q = $wpas->query(); $template = $wpas->get_ajax()->resultsTemplate(); $response = array(); $response["results"] = wpas_load_template_part($template, $q); $response["current_page"] = $q->query_vars['paged']; $response["max_page"] = $q->max_num_pages; if ($response["results"] === false) { $wpas->set_error("AJAX results template '" . $template . "' not found in theme root."); } $response["debug"] = ""; if ($wpas->debug_enabled()) { $response["debug"] = "<pre>" . $wpas->create_debug_output() . "</pre>"; } return json_encode($response); }
<?php $args = array(); $args['wp_query'] = array('post_type' => 'post', 'posts_per_page' => 5, 'order' => 'DESC', 'orderby' => 'date'); $args['fields'][] = array('type' => 'search', 'label' => 'Search', 'value' => ''); $args['fields'][] = array('type' => 'post_type', 'label' => 'Post Type', 'values' => array('post' => 'Post', 'page' => 'Page'), 'format' => 'select'); $args['fields'][] = array('type' => 'taxonomy', 'label' => 'Category', 'taxonomy' => 'category', 'format' => 'multi-select', 'operator' => 'AND'); $args['fields'][] = array('type' => 'taxonomy', 'label' => 'Tags', 'taxonomy' => 'post_tag', 'format' => 'checkbox', 'operator' => 'IN'); $args['fields'][] = array('type' => 'date', 'label' => 'Month', 'date_type' => 'month', 'format' => 'multi-select'); $args['fields'][] = array('type' => 'orderby', 'label' => 'Order By', 'values' => array('' => '', 'ID' => 'ID', 'title' => 'Title', 'date' => 'Date'), 'format' => 'select'); $args['fields'][] = array('type' => 'order', 'label' => 'Order', 'values' => array('' => '', 'ASC' => 'ASC', 'DESC' => 'DESC'), 'format' => 'select'); $args['fields'][] = array('type' => 'submit', 'value' => 'Search'); $my_search_object = new WP_Advanced_Search($args); $my_search_object->the_form(); $temp_query = $wp_query; $wp_query = $my_search_object->query(); if (have_posts()) { while (have_posts()) { the_post(); ?> <h2><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <p><strong>Author:</strong> <?php the_author(); ?> <strong>Date:</strong> <?php
//$args['relevanssi'] = true; //instantiate search $speaker_search = new WP_Advanced_Search($args); ?> <h1 class="pagetitle"><span>Speaker Program</span></h1> <div id="speakertabs" class="speakertabs"> <div id="tabs-1"> <?php //show the form ?> <a id="search-toggle" href="#" class="search-toggle collapsed">Advanced Search</a> <?php $speaker_search->the_form(); $query = new WP_Query(); $query = $speaker_search->query(); ?> <div class="search-results"> <?php if ($query->have_posts()) { ?> <table class="speaker-archive-table" id="speaker-archive-table"> <thead> <tr> <th>Speaker Link</th> <th>Date</th> <th>Program Title</th> <th>Name</th> <th>Job Title/Organization</th>
} ?> <?php if ($sd_data['sd_sidebar_location'] == '2') { echo 'pull-right'; } ?> "> <div class="sd-left-col"> <?php global $wp_query; global $more; $more = 0; $args = sd_wp_advanced_search(); $sd_search_course = new WP_Advanced_Search($args); $wp_query = $sd_search_course->query(); if (have_posts()) { while (have_posts()) { the_post(); ?> <?php get_template_part('framework/inc/post-formats/courses/content', get_post_format()); ?> <?php } } else { ?> <p> <?php _e('Sorry, no results matched your criteria', 'sd-framework'); ?>
<?php /*Template Name: Search */ get_header(); ?> <?php if (is_user_logged_in()) { ?> <div class="inner cover"> <div class="projects-wrapper clearfix"> <?php $my_search = new WP_Advanced_Search('my-form'); $query = $my_search->query(); ?> <?php if ($query->have_posts()) { ?> <ul> <?php while ($query->have_posts()) { $query->the_post(); ?> <?php $status = get_field('completed'); ?> <li class="project"> <a href="<?php