Enable Search suggestions for custom post types

By default, the theme Search element display suggestions for default post types (Posts, Pages, Portfolio and Products), however, if you have custom post types on your WordPress site and want to include these custom post types in the search suggestions you can use the filter pixfort_search_post_type which passes an array of the default post types that are included in search suggestions, for example to enable suggestions for “download” custom post type you can add the following code to the child theme functions.php file:

function example_search_post_types($post_types) {
    array_push($post_types, "download");
    return $post_types;
add_filter( 'pixfort_search_post_type', 'example_search_post_types' );

After that the Search suggestions will include the custom post type items in case they match the search criteria.

Are you looking to customize the search suggestion to search in a specific post type only?

For example, if you are looking to customize the search suggestions to include only “product” post type (from WooCommerce plugin), then you can use the following code snippet into your child theme:

function example_search_product($post_types) {
    $post_types = ["product"];
    return $post_types;
add_filter( 'pixfort_search_post_type', 'example_search_product' );
Essentials support team

Hey, this is pixfort support team, if you still need help you can always reach us via the chat messenger in your account on pixfort hub

Related Posts