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