Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3802935
Custom post type
Open

Comments

  •  1
    Neil started the conversation

    Hi, as part of our ecommerce offering we sell custom post type batch items. This is achieved by using a plugin which extends WooCommerce by allowing a custom post type (CPT) to be added. 

    We are now looking to add smart search and want the batch custom post types to be taken into account. We have tried filters like the below but we are finding that the search results are inconsistent and not reliable. How can we include this post type? 

    Filter:

    add_filter('wpcas_search_query_args', 'include_custom_post_types_in_search');
    function include_custom_post_types_in_search($args) {

        // Add custom post types to the search query
        $args['post_type'] = ['posts', 'pages', 'products', 'batch'];

        return $args;

    }

    Thanks

  •  1,355
    Dustin replied

    Hi Neil,

    By default, this plugin is used to search for products. Therefore, returning the result only shows products with the post type 'product' even if you have added filters for post types in the query.

    We'll soon add an option to allow you to choose product types when searching.

    Best regards,
    Dustin