• Resolved Nikos Kavvadas

    (@nikoslefkas)


    Hello there!

    I am using your theme in all my websites, and I am completely satisfied with Blocksy.

    This is the first time that I have an issue and I need your help.

    I want to exclude a Custom Type Posts from my website search.

    From theme customization options I found the way to exclude the ctp from the header search option.

    But when I am using the search widget in the search result (also in live search results) the ctp are showing. How can I exclude the ctp also from search widget results?

    Can you please help me ?
    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @nikoslefkas

    Could you please let me know which widget exactly you have used?

    Thanks!

    Thread Starter Nikos Kavvadas

    (@nikoslefkas)

    Hi Eduard!
    Thank you for your fast response!

    I used the default search widget (check my screenshot here: https://freeimage.host/i/26zhr0X )

    I think I solved by adding the following code in functions.php

    //Εμφ?νιση στην αναζ?τηση μ?νο των ?ρθρων - λημμ?των
    if (!is_admin()) {
    function search_filter_posts($query) {
    if ($query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }
    add_filter('pre_get_posts','search_filter_posts');
    }

    So now the search show only posts, not pages, not ctp.

    Can you suggest me another solution?

    Thank you, once again!
    Nikos

    Hello @nikoslefkas

    From what I can see, you’re using the classic widgets system and the built in search widget. I’m afraid that we do not have control over these and we cannot provide advice for how to modify them, or debug any code snippets related to them. And in addition to that, the classic widgets system has an unsupported status in combination with Blocksy, as the theme is Gutenberg based. Things might not work as expected.

    What would be recommended is to switch to the standard widget editor (based on Gutenberg) and use our own Advanced Search widget: https://creativethemes.com/blocksy/docs/theme-blocks/advanced-search/. It has direct options to select which post types are searched and can be managed with ease.

    Hope this clears things up!

    Thanks.

    Thread Starter Nikos Kavvadas

    (@nikoslefkas)

    Hi Eduard!

    With the above code, the search widget works only with posts!
    So everything is ok!

    Thanks so much for your assistance!
    Nikos

    Eduard

    (@cteduard)

    Hello @nikoslefkas

    Alright, no problem. Thanks for letting me know. ??

    Take care.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.