Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // overwrite search plugin output
- function customize_ultimate_output($results , $arg, $id, $getdata ){
- $sex = $arg['meta_query'][1]['value'];
- $sex_compare = $arg['meta_query'][1]['compare'];
- $age = $arg['meta_query'][2]['value'];
- $age_compare = $arg['meta_query'][2]['compare'];
- $city = $arg['meta_query'][3]['value'];
- $city_compare = $arg['meta_query'][3]['compare'];
- if ( isset($getdata['cmf'][3]['value']) ) {
- $services = $getdata['cmf'][3]['value']; // value = array()
- } else {
- $services = false;
- }
- $search_term = $arg['s'];
- $posts_per_page = $arg['posts_per_page'];
- $post_type = $arg['post_type'];
- $post_status = $arg['post_status'];
- $orderby = $arg['orderby'];
- $order = $arg['order'];
- $meta_key = $arg['meta_key'];
- $meta_query = array();
- $tax_query = array();
- $compare = '';
- $orderby = false;
- $paged = false;
- $meta_key = NULL;
- $new_args = array(
- 'post_type' => $post_type,
- 'posts_per_page' => $posts_per_page,
- 'meta_key' => $meta_key,
- 'orderby' => $orderby,
- 'order' => $order,
- 'paged' => $paged,
- 'meta_query' => array(
- 'relation' => '',
- array(
- 'key' => 'dvp_sex',
- 'value' => $sex,
- 'compare' => $sex_compare,
- ),
- array(
- 'key' => 'dvp_age',
- 'value' => $age,
- 'compare' => $age_compare,
- ),
- array(
- 'key' => 'dvp_city',
- 'value' => $city,
- 'compare' => $city_compare,
- ),
- array(
- 'key' => 'dvp_services',
- 'value' => $services,
- 'compare' => '='
- ),
- ),
- 's' => '',
- );
- // echo '<pre>'; var_dump($new_args); echo '</pre>';
- // exit;
- // The (Original) Query
- $apiclass = new uwpqsfprocess();
- $wp_query = new WP_Query( $new_args );
- ob_start();
- $result = '';
- // The Loop
- if ( $wp_query->have_posts() ) :
- $countquery = $wp_query->found_posts;
- $what = 'result';
- if ( $countquery > 1 ) {
- $what .= 's';
- }
- echo '<p>We found '.$countquery.' ' . $what . ' matching your criteria.</p>';
- // echo $apiclass->ajax_pagination( $arg['paged'], $wp_query->max_num_pages, 10, $id, $getdata );
- // 2do: add list header
- while ( $wp_query->have_posts() ) : $wp_query->the_post();
- echo '<p><a href="'.get_the_permalink().'">'.get_the_title().'</a></p>';
- endwhile;
- // 2do: add list footer
- echo $apiclass->ajax_pagination( $arg['paged'], $wp_query->max_num_pages, 20, $id, $getdata );
- else : // if no posts
- echo '<p>'; __('Nothing found', 'dvp'); echo '</p>';
- endif;
- /* Restore original Post Data */
- wp_reset_postdata();
- $results = ob_get_clean();
- return $results;
- }
- add_filter('uwpqsf_result_tempt', 'customize_ultimate_output', '', 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement