-
Author
-
December 24, 2017 at 19:24 #183837GrantParticipant
Hi Guys,
Is there a way to control what the Ajax Search tool searches?
I only want it to search certain pages/posts. At the moment, it brings back everything! – Members, posts, pages, images, all sorts of stuff that I don’t want the users to see.
Can the search criteria be more tightly controlled?
Thanks,
Grant
December 24, 2017 at 19:34 #183838Kieran_SQModeratorHi Grant,
You can control the post types for ajax search by going to Theme Options > Header Options > Scroll to: ‘Search context’. Select the input to the right and add or remove post types as required.
If you’d like to exclude specific pages / posts from being returned in any of your search results you’ll need to install a plugin. There are many available for free in the WordPress plugin repository but this one may be of use you you https://wordpress.org/plugins/search-exclude/.
Thanks,
Kieran
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
Attachments:
You must be logged in to view attached files.December 24, 2017 at 19:40 #183841GrantParticipantKieran,
Clearly I’m a bit half asleep today mate. This one I should have noticed!!
Thanks so much for being so quick off the mark. Now it’s Xmas – go have some fun!! :))
Grant
December 24, 2017 at 19:44 #183842Kieran_SQModeratorHi Grant,
No worries at all, it happens to the best of us! I shall try to have as much fun as one can when stuck in a hotel because of a gas leak during an ice storm lol. But seriously thank you very much, Merry Christmas to you and yours.
All the best,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
December 25, 2017 at 00:52 #183851GrantParticipantHey Mate,
Hope you were joking about your Xmas dilemma. If not, there’s always the local hotel bar! 🙂
Anyway…if you’re still up for a bit of a challenge, here’s a tougher one. I’m nearing the end of some testing for a membership that site I’ll be bringing online soon. I use an account to update various pages, posts and so forth on the sit but I want to ‘hide’ that account from any ajax search’s that a user or member might make. Unless you know a better way to use an ‘author’ account that doesn’t get recognised by WordPress or BuddyPress anywhere on a site.
If not, I’m wondering if you have a function anywhere which can just hide some account/s from showing up in the ajax search bar.
Cheers my friend – Stay warm, have some Mulled wine….nice!
Grant
December 26, 2017 at 18:42 #183902Kieran_SQModeratorHi Grant,
Unfortunately it was no joke! We have a Christmas curse in our family.
With regards to your question you should able to use the snippet provided from this article in your KLEO Child theme’s functions.php file to hide members from your search results https://archived.seventhqueen.com/kleo/article/hide-admin-members-directory.
COPY CODEadd_action('bp_ajax_querystring','sq7_radu_exclude_users',20,2); function sq7_radu_exclude_users($qs=false,$object=false){ //list of users to exclude $excluded_user = '1';//comma separated ids of users whom you want to exclude if($object!='members')//hide for members only return $qs; $args=wp_parse_args($qs); //check if we are searching for friends list etc?, do not exclude in this case if(!empty($args['user_id'])||!empty($args['search_terms'])) return $qs; if(!empty($args['exclude'])) $args['exclude']=$args['exclude'].','.$excluded_user; else $args['exclude']=$excluded_user; $qs=build_query($args); return $qs; }
You will need to change the line that states $excluded_user = ‘1’ to suit your needs. If you need to hide more than one you can do this by using comma separated values in the same line mentioned above $excluded_user = ‘1, 19, 42’.
Thanks,
Kieran
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
December 29, 2017 at 00:35 #184149GrantParticipantHey Mate,
Very dodgy…bit of a naughty family history eh…Santa’s not impressed! 😉 Well, despite the issues, I hope it wasn’t too bad.
I did try that script. While it does hide the members from the member search, it does NOT hide them from the Kleo AJAX search. That search still finds the members.
Any other possible thoughts?
Cheers,
Grant
December 29, 2017 at 03:12 #184156Kieran_SQModeratorHi Grant,
I will refer this ticket to one of our developers to look into this for you. They’ll be in touch as soon as they can, Monday to Friday, East European Time.
I managed to get back home with the heating fixed just in time for -22° C temps, fingers crossed for an uneventful new year, hope you and yours have a great new year.
All the best,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
December 29, 2017 at 15:43 #184205GrantParticipantThanks Kieran,
Here’s hoping your New Year is a little warmer!
Cheers!
January 3, 2018 at 18:46 #184618RaduModeratorHi,
So while using short code you can set the search context like this
COPY CODE[kleo_search_form context="members,groups,post,page,product,portfolio"]
IF you want to hide member results just delete the members,
If you are talking about the ajax menu search the context it can be controlled from wp-admin -> theme options -> header options -> search context
Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.