This topic has 9 replies, 3 voices, and was last updated 6 years by Radu.

  • Author
  • #183837
     Grant
    Participant

    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

    #183838
     Kieran_SQ
    Moderator

    Hi 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 solution

    If 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.
    #183841
     Grant
    Participant

    Kieran,

    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

    #183842
     Kieran_SQ
    Moderator

    Hi 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 solution

    If 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.

    #183851
     Grant
    Participant

    Hey 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

    #183902
     Kieran_SQ
    Moderator

    Hi 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 CODE
    add_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 solution

    If 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.

    #184149
     Grant
    Participant

    Hey 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

    #184156
     Kieran_SQ
    Moderator

    Hi 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 solution

    If 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.

    #184205
     Grant
    Participant

    Thanks Kieran,

    Here’s hoping your New Year is a little warmer!

    Cheers!

    #184618
     Radu
    Moderator

    Hi,

    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
Viewing 10 posts - 1 through 10 (of 10 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?