Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Showing the search results on the search page (i.e. going without the Ajax) › Reply To: Showing the search results on the search page (i.e. going without the Ajax)
Here is the finished working code; I had to go against good practice a bit and make a new function in search.php that is an exact close of ajaxsearchpro_search except for one caveat; it returns the results instead of printing them:
<?php if(isset($_GET[“s”])):
require_once(ABSPATH . ‘wp-content/plugins/ajax-search-pro/search.php’);
$_POST[“aspp”] = $_GET[“s”];
$_POST[“action”] = “ajaxsearchpro_search”;
$_POST[“asid”] = 2;
$_POST[“options”] = “qtranslate_lang=0&set_intitle=None&set_incontent=None&set_inexcerpt=None&set_inposts=None&set_inpages=None&set_inbpgroups=None&set_inbpusers=None&customset%5B%5D=event&customset%5B%5D=speakers&customset%5B%5D=location&categoryset%5B%5D=2&categoryset%5B%5D=3&categoryset%5B%5D=4&categoryset%5B%5D=1&categoryset%5B%5D=5&categoryset%5B%5D=6&categoryset%5B%5D=7”;
echo “<h1>Search: “.$_POST[“aspp”].”</h1>”;
$results = json_decode(ajaxsearchpro_search_two());
$html = “”;
foreach($results as $p):
$html .= “<div class=’search-result-item’>”;
$html .= “link.”‘><h3 style=’margin-top:5px;’>”.$p->title.”</h3>“;
$html .= ““.$p->author.”“;
$html .= “<p>”.stripslashes($p->content).”image.”‘ style=’float:left;’/></p>”;
$html .= “link.”‘>View More“;
$html .= “</div>”;
endforeach;
echo $html;
//$_posts = new wpdreams_searchContent($params);
//$pageposts = $_posts->search($s);
else: ?>
<?php get_template_part( ‘content’, ‘page’ ); ?>
<?php endif; ?>
Obviously the html needs to be styled but it works! In fact, I’m not even using the ajax search pro form for my search!!!! I really would be a proponent of you adding a feature like this to your plugin that allows for the default WP search to utilize your *AMAZING* searching algorithm, cause legit it is one of the best I’ve seen and/or used (the other one being relevanssi, though the free version doesnt search BP which is a pain)