Ajax WP Query Search Filter
Over last few month, I have been developing this new plugin. And now, finally it’s done.
Let me present you my new plugin Ajax WP Query Search Filter. Yes, it is another wordpress search plugin. As the name suggested, it is pretty much similar to my previous plugin Advance WP Query Search Filter which, let you perform more precisely search by filtering the search through post type, taxonomy and meta field. But instead of display the search result in new page, this plugin will display the search result in the same page via Ajax Calling.
Plugin Features:
- Admin are free to choose whether the search go through post type, taxonomy, meta field or even all of them.
- Multiple Search Form Supported.
- Search form support checkbox,radio and dropdown fields.
- Using Ajax to display result in the same page complete with pagination.
- Plugin extendable with hooks.
- Using shortcode to display the search form.
Installation:
- Upload
ajax-wqsf
folder to the/wp-content/plugins/
directory - Activate the plugin through the ‘Plugins’ menu in WordPress
- Create your search form in the Advance WQSF.
- Using
[AjaxWPQSF id={form id}]
to display the form.
FAQ:
How can I styling the search form?
You can simply refer the awqsf-style.css.css that come with the folder and alter it or override it at your theme css file.
What if I want to display the search form in the template?
Put this into <?php echo do_shortcode("[AjaxWPQSF id={form id}"); ?>
your template.
What if I want to display the search form in the sidebar widget?
Just insert the shortcodes like you inserted in the post content. eg. ‘[AjaxWPQSF id=3299]`
What if I don’t want to display the title of the search form?
Just giving 0
to formtitle
atribute in the shortcode eg. ‘[AjaxWPQSF id=3299 formtitle=”0″]`
HOOKS
1. ajax_wpqsf_reoutput() filter hook.
For customize the searched result layout and content.
eg.
add_filter('ajax_wpqsf_reoutput', 'customize_output', '', 4);
function customize_output($results , $arg, $id, $getdata ){
// The Query
$apiclass = new ajaxwpqsfclass();
$query = new WP_Query( $args );
ob_start(); $result = '';
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
echo '<li>'.get_permalink().'</li>';
}
echo $apiclass->ajax_pagination($arg['paged']
,$query->max_num_pages, 4, $id);
} else {
echo 'no post found';
}
/* Restore original Post Data */
wp_reset_postdata();
$results = ob_get_clean();
return $results;
}
[h5-donation id=”1″ ]
Notice: Now the comment area has been closed. Please use our new support forum to post your question. Thanks!
Visit Ajax WP Query Search Filter Support Forum
Mike
What perfect timing! I just typed in “wordpress ajax search filter” in Google & they showed your plugin posted 10 hours ago! Looking forward to checking it out & am glad to see there’s a good developer behind it. If I end up using it, I’ll be sure to donate 🙂
Mike
Okay, I checked it out. Love the simplicity & good call on the results hook.
It seems like it’s smart to put the search form & results in two different divs. Whenever I had a problem such as not being able to click on more pages, it seemed to be because of them being in the same div. Also, I think it’s just good usability to have the search box always show while the results show below it or to the side.
There are only two things I can think of that I would really like in addition & that is:
1) Ajax search bar suggestions &
2) The ability to check a value when results are displayed & have the results filter without having to click search again.
Let me know if you were thinking of potentially adding these.
Great job though. Going to play around with it some more & test the limits 🙂
tck30
Hi, thanks for your comment.
Yes, the div for the result should not same as the form displayed div.
I am not thinking of adding search bar suggestions for the moment, maybe I will add it in the future, but I can’t promise anything right now.
As for the second suggestion, when I first create this plugin, there were no Search button in form. Whenever user make a changes in the search form input, the result will display instantly. I asked people about this feature, but most of them prefer having “Search” button in the form, so I dropped this feature eventually. likewise, I will not add this feature to the plugin for the moment,
Mike
Cool. Makes sense! To be more clear, I meant that the search is the only thing that wouldn’t automatically update. So, you could search, but then automatically filter with the static options like for example, behance.net does. I agree with you on the search though. Thanks 🙂
tck30
I see what you meant. I don’t think I will add this to my plugin. Actually if you want to hold the filter input, you can simply use checkboxes instead. But it is not pretty as the example you gave me though.
Mike
Good point! Maybe I’ll create a custom dropdown with the checkboxes.
Swetha
HI,
This is a great search plugin. I want to use it to retrieve data from contact form db plugin and display in the website front end. How to achieve this? I am using contact form 7 for the forms.
Another question is what is taxonomy as mentioned in your plugin. Where do we get this or define this?
Thanks,
Swetha
tck30
I am not quite sure how Contact From 7 store the data. If it is using wp_posts to store data, it probably achievable.
For more info about taxonomy, you can read from this blog. Very good explanation.
Suzanne Chiles
This plugin looks like it’s going to work well for me. It’s been easy to create the query and place it on the page with the shortcode. I’m getting the results that I expect too. Fantastic!
I want my queries to return just a list of hyperlinked topics, not the full post. Can you point me in the right direction control the results?
Thanks!
tck30
Yes, you can, just refer to the ajax_wpqsf_reoutput() at above. Add it in your function.php. For example:
add_filter('ajax_wpqsf_reoutput', 'customize_output', '', 2);
function customize_output($results , $args){
// The Query
$query = new WP_Query( $args );
ob_start(); $results ='';
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
echo '
';
}
} else {
echo 'no post found';
}
/* Restore original Post Data */
wp_reset_postdata();
$results = ob_get_clean();
return $results;
}
Suzanne Chiles
Can you clarify the code to use on the line to ‘.get_the-title(). I’m getting no post found .. and I know there are posts.
Sorry … this is a little advanced for me.
Thanks.
tck30
The get_the_title() is to get the post title. The code I give you is just an example.
In the “while” loop is where you customize your result. If you want to get the post link you can use: get_permalink(); instead. Or combine both of the function like here.
If there are no post found mean there is something wrong with the query,check again to see is there any error input/setting in the form.
Tom
HI ! This is a really nice plugin! I tried your NON-AJAX version and it appears to be working! ….. but the AJAX version I just downloaded and tried to configure – and I got an error in PROCESS.php
Warning: in_array() expects parameter 2 to be array, null given in PATH / wp-content/plugins/ajax-wp-query-search-filter/classes/process.php on line 22
I didn’t do anything differently than your NON-ajax version. Can you advise? I would be most grateful!
A thousand thanks.
Tom
Tom
PS… I just removed the plugin and deleted it. And downloaded it again. It seems this error is coming up right as soon as the plugin is installed.
tck30
It is because you didn’t choose the theme in the form setting page. Goto check the default theme (radio button) in the form setting page.
Tom
HI again . Big thanks for your response! I noticed that “Default Theme” with radio button is misspelled: “DEFUALT Theme” . So looked and found it also misspelled in misc.php
—->> line 13
—->> $defualtresult = get_option(‘posts_per_page’);
So I changed it to $defaultresult …. and the error disappeared!
Please check your misc.php for this.
Thank you!
Once I have some time to try out this AJAX version I will look forward to getting back to you.. MANY THANKS!
tck30
Thanks for pointing it out. I will fix this very soon.
Tom
Hello again! Thank you! Noticed you updated the plugin today – so I downloaded it and now installation produces no errors.l Wonderful. However, I have tried your AJAX version now, and have a question.
lets say I create a dropdown for 2 categories
CAT1
CAT2
…. AND I create a dropdown for 3 taxonomies in each category
CAT1-TAXO1
CAT1-TAXO2
CAT1-TAXO3
CAT2-TAXO1
CAT2-TAXO2
CAT2-TAXO3
QUESTION: If I select CAT1 from the top…. HOW can I automatically HIDE the CAT2 items from the list below?? I really want dropdown#2 to change based on my selection in dropdown#1.
I am very stuck on this and would be thrilled if you can give me a push in the right direction.
Great plugin so far!
Tom
tck30
Well this is dynamic dependant dropdown, which not easy to achieve.
However, you can try use jquery to hide or show based on the category selection.
Marie LaForte
Hi,
I am developing a site and have installed the ajax version search. I am trying to get one of the meta value fields to display on the search results page…just don’t know how. The value is price and it is one of the search values on the form. I have tried many different ways of adding the meta value on the process.php page but it won’t display the price. I am not a programmer and have tried to copy other php code from the web and the jigoshop code(that is what I am using to display the properties on this site. I was ale to add post values to the search result but no meta values. Can anyone help??
Thanks in advance,
tck30
Refer on the ajax_wpqsf_reoutput() filter above, You should use the get_post_meta() in the while loop.
Example here.