Advertisement
Guest User

wordpress code

a guest
Jul 3rd, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. <?php
  2.  
  3. $path = dirname(dirname(dirname(dirname(__FILE__))));
  4. require_once($path.'/wp-config.php');
  5.  
  6. function autocompleter()
  7. {
  8.     $results = (get_option('autocompleter_results')!= false)?get_option('autocompleter_results'):1;
  9.     $wpdb =& $GLOBALS['wpdb'];
  10.     $search = $wpdb->escape($_GET['q']);
  11.     if(strlen($search)){
  12.         switch($results){
  13.             case 7: //Go GeoTheme
  14.                 $words1 = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
  15.                 if($_SESSION['multi_city']){
  16.                 $multi_city_id = mysql_real_escape_string ($_SESSION['multi_city']);
  17.                 $words2 = $wpdb->get_results("SELECT DISTINCT post_title as name FROM $wpdb->posts join $wpdb->postmeta on $wpdb->postmeta.post_id=$wpdb->posts.ID where $wpdb->posts.post_status='publish' and $wpdb->posts.post_type in ('place','event') AND  ($wpdb->posts.ID in (select $wpdb->postmeta.post_id from $wpdb->postmeta where $wpdb->postmeta.meta_key='post_city_id' and ($wpdb->postmeta.meta_value in ($multi_city_id) )))and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
  18.                 }else{
  19.                 $words2 = $wpdb->get_results("SELECT post_title as name FROM $wpdb->posts where post_status='publish' and post_type in ('place','event') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");  
  20.                 }
  21.                 $words = array_merge((array)$words1 ,(array)$words2 );
  22.                 break;
  23.         }
  24.        
  25.        
  26.        
  27.         foreach ($words as $word){
  28.             if($results > 3)
  29.                 echo $word->name."|".get_permalink($word->ID)."\n";
  30.             else
  31.                 echo $word->name."\n";
  32.         }
  33.     }
  34.  
  35. }
  36. if($_GET['q']){
  37.     autocompleter();
  38. }
  39.  
  40.  
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement