This topic has 7 replies, 2 voices, and was last updated 11 years by BDecker19.

  • Author
  • #49379
     BDecker19
    Participant

    Having trouble getting it to display the right result types in our ajax search menu. I’ve set our options NOT to include pages, but they keep showing up. See screenshots attached.

    Thanks!
    Benji

    #49382
     BDecker19
    Participant

    Update, i’ve added the code below, and it seems to have mostly solved the problem:

    COPY CODE
    // Avoid page results in ajax search
    
    function filter_search($query) {
        if ($query->is_search) {
        	$query->set('post_type', array('post', 'event', 'product', 'topic'));
        };
        return $query;
    };
    add_filter('pre_get_posts', 'filter_search');
    

    Only issue now is with one of the post types (“Event”), it doesn’t seem to be displaying a header category — see screenshot. Is there any way I can adjust this? Or if there’s an alternative solution to the original problem, that works as well!

    #49387
     sharmstr
    Moderator

    You’re setting it up wrong. The options in Theme Options are for the search in the menu.

    You need to go into page editor for that page and change the options on the search form shortcode.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #49388
     BDecker19
    Participant

    interesting. ok, lemme check. although I’m getting pages in the results there too? screenshot attached.

    #49390
     sharmstr
    Moderator

    The filter definitely works on a non modified install of kleo.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #49393
     sharmstr
    Moderator

    For what its worth, something I find really helpful is a vanilla install of Kleo. I can use that to see if I’ve, or a plugin has screwed up the default functionality of Kleo.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #49394
     BDecker19
    Participant

    that’s code for you’re not able to support here?

    #49395
     BDecker19
    Participant

    ok, yeah — i can try that

Viewing 8 posts - 1 through 8 (of 8 total)

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

Log in with your credentials

Forgot your details?