Advertisement
nefi_c

Gform dealer code

Jan 29th, 2013
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. function get_dealer_name_fn(){
  2.     $dealerCounty = $_POST['dealerCounty'];
  3.     $dealers = get_posts(array(
  4.         "post_type" => "dealer",
  5.         "dealer-country" => $dealerCounty,
  6.         "post_status" => "publish",
  7.         "orderby" => "title",
  8.         "order" => "ASC",
  9.         "posts_per_page"  => -1
  10.     ));
  11.  
  12.     $items = array();
  13.     $items[] = array( "text" => __('Select dealer...','mission-theme'), "value" => 0 );
  14.     foreach($dealers as $dealer){
  15.         $items[] = array( "text" => $dealer->post_title, "value" => $dealer->post_name );
  16.     }
  17.    
  18.     echo json_encode($items);
  19.     die;
  20. }
  21. add_action('wp_ajax_get_dealer_name', 'get_dealer_name_fn');
  22. add_action('wp_ajax_nopriv_get_dealer_name', 'get_dealer_name_fn');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement