• Hi, I’m using the free version of SearchWP and I’m trying to modify the default WordPress search results to:

    1. Only include post and page post types
    2. Exclude a specific post category (ID 10)

    I tried the usual method via pre_get_posts, setting 'post_type' => ['post', 'page'] and 'cat' => -10. This works fine in the normal search results, but in the Live Ajax Search, custom post types like glossary are still included in the search results.

    I also tried using the the_posts filter to manually remove any non-post/page items and exclude category 10, but it still doesn’t work – those CPTs continue to appear in results.

    I believe the plugin is overriding the query or injecting results in a way that bypasses these filters.
    How can I ensure that SearchWP respects post type and category filtering in the free version?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Plugin Support Karan

    (@kjswp)

    Hi @benniledl ,

    I would like to inform you that the free Live Search plugin uses the default WP_Query and is therefore compatible with the pre_get_posts hook.

    To use this hook properly, ensure that the SearchWP premium plugin is not active. Additionally, Live Search retrieves results via admin AJAX requests. If your conditions restrict searches to the frontend only, they may not work with AJAX-based requests.

    Alternatively, you can use the following hook to filter Live Search AJAX results:
    apply_filters( 'searchwp_live_search_query_args', $args );

    For more details on available arguments, please refer to the documentation guide.

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