Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Build in search modal

  • Hi –

    I have a question to the built in search modal.
    How much do it search in – is it only WP page and post content?

  • Hi there,

    By default, the built-in search only returns results from posts and pages. However, this can be changed — let us know what other content types (like products, or custom post types) you’d like to include in the search results.

  • OK, thanks for the answer.

    Would it be possible to include Pages, Elements, Woocommerce products etc. and ACF?

  • For WooCommerce products, I think they’re usually included in search results by default also. You can use this snippet to include other post types as well:

    function include_custom_post_types_in_search($query) {
        if ($query->is_search && !is_admin()) {
            $query->set('post_type', array('post', 'page', 'your_custom_type'));
        }
        return $query;
    }
    add_filter('pre_get_posts', 'include_custom_post_types_in_search');

    Just replace your_custom_type with your actual custom post type slug.

    Curious though — what’s the reason you want to include Elements in the search results?

  • Thanks Alvind 🙂

    I have a number of ACF templates for single posts and related posts, which are made in elements. I would like to be able to search all the posts that are generated via ACF…

  • I would like to be able to search all the posts that are generated via ACF…

    I’m not sure what this means… posts are posts, are they not the post post type?

  • Yes, I can see that I haven’t expressed myself clearly.
    What I want is to search in ACF fields. How do I extend the search to these fields as well?

  • Do you mean the values of ACF custom fields assigned to a post types?

    If so, unfortunately I don’t think that’s possible.

  • OK, thanks for your time 🙂

  • No problem 🙂

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