• Hi, great plugin, I’m using the free version, how can I exclude pages? Is there a way to exclude pages via code without purchasing the pro version? Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Karan

    (@kjswp)

    Thank you for sharing your positive feedback.

    We’re glad to hear that you’ve found the SearchWP Live Ajax Search plugin useful for your site.

    Regarding your query, I would like to clarify that the free Live Ajax Search plugin uses the default WordPress query to find results. Because of this, you can use another plugin, such as Search Exclude to remove any post or page from appearing in the live search results.

    Additionally, you can use the following custom code to exclude all pages from search:

    function exclude_post_types_from_search($query) {
    if ($query->is_search()) {
    $excluded_post_types = array('page'); // Replace with post types to exclude

    $post_types = get_post_types(['public' => true], 'names');
    $query->set('post_type', array_diff($post_types, $excluded_post_types));
    }
    }
    add_action('pre_get_posts', 'exclude_post_types_from_search');
    Thread Starter serialcode

    (@serialcode)

    This is what I need! Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this review.