Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 1.78 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to use do_shortcode outside of a template
  2. category = $("#past_vendor_category").val();
  3. search_term = $("#past_vendor_name").val();
  4.  
  5. $.post("http://localhost/wordpress/wp-content/search_past_vendors.php", { category: category, search_term: search_term }, function(results){
  6.     $("#past_vendor_search_results").html(results);
  7. });
  8.        
  9. <?php
  10. global $shortcode_values, $theLayout;
  11. include "config.php";
  12. $category = mysql_real_escape_string($_POST['category']);
  13. $search_term = mysql_real_escape_string($_POST['search_term']);
  14.  
  15. $qry = "Select wp_posts.ID, wp_posts.post_name, wp_posts.post_title, custom_vendor_info.city, custom_vendor_info.city
  16. from wp_posts
  17. join custom_vendor_info on wp_posts.ID=custom_vendor_info.post_id
  18. join wp_term_relationships on wp_posts.ID=wp_term_relationships.object_id
  19. where wp_posts.post_title like '%$search_term%' and wp_term_relationships.term_taxonomy_id='$category'";
  20. $result = mysql_query($qry);
  21. $resultrows = mysql_num_rows($result);
  22. $x=0;
  23. if($resultrows>0){
  24.     $show_results = '<br>';
  25.     while($resultset = mysql_fetch_array($result)){
  26.         if($x==0){
  27.         $show_results .= '<div class="vendor_search_result"><span class="vendor_search_result_name"><a href="'.$resultset['post_name'].'">'.$resultset['post_title'].'</a></span><span class"vendor_search_result_button">'.do_shortcode("[button]Text[/button]").'</span>';
  28.         }else{
  29.         $show_results .= '<div class="vendor_search_result"><span class="vendor_search_result_name"><a href="'.$resultset['post_name'].'">'.$resultset['post_title'].'</a></span><span class"vendor_search_result_button">'.do_shortcode("[button]Text[/button]").'</span>';
  30.         $x=0;
  31.         }
  32.     }
  33.     echo $show_results;
  34. }else{
  35.     echo '<br>Sorry, there were no search results for "<b>'.$search_term.'</b>". Please try again!';
  36. }
  37. ?>