Support » Theme: Hueman » Search no results

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Your search result page is cached by your cache plugin.
    You need to exclude search and search results from caching.

    Please contact your cache plugin support for further assistance.

    Thank you.

    Thread Starter fususu

    (@fususu)

    I’ve resolved it by myself. In the functions.php I have some code that filter the woocommerce product & page from search, it also filtered everything T_T so I fixed the code and it works perfectly now.

    In case someone needed it. These code below will hide product of woocommerce and page in the post search.

    /* hide product in search */
    add_action( 'init', 'update_my_custom_type', 99 );
    function update_my_custom_type() {
    global $wp_post_types;
    if ( post_type_exists( 'product' ) ) {
    // exclude from search results
    $wp_post_types['product']->exclude_from_search = true;
    }
    }
    
    /* hide page from search */ 
    function SearchFilter($query) {
    if (!is_admin() && $query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }
    
    add_filter('pre_get_posts','SearchFilter');
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search no results’ is closed to new replies.