Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. function bpd_ajax_filter_search_callback() {
  2.   if(isset($_POST['search'])) {
  3.     $searchterm = esc_attr( $_POST['search'] );
  4.     $args = array(
  5.       'posts_per_page' => -1,
  6.       'post_status' => 'publish',
  7.       'post_type' => 'product',
  8.       's'   => $searchterm
  9.     );
  10.   }
  11.  
  12.   $the_query = new WP_Query($args);
  13.  
  14.   if($the_query->have_posts()):
  15.       while($the_query->have_posts()):
  16.           $the_query->the_post();
  17.           the_title();
  18.           echo '<br>';
  19.       endwhile;
  20.       wp_reset_query();
  21.   endif;
  22.  
  23.   die;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement