Friday, November 4, 2022
HomeWordPress Developmentphp - Conceal out of inventory merchandise in house pagenot within the...

php – Conceal out of inventory merchandise in house pagenot within the catalog


I understand how to cover the merchandise from catalog since Woocommerce settings however i want to cover out of inventory merchandise in some pages, i’ve this code:

add_action( 'pre_get_posts', 'misha_hide_out_of_stock_in_search' );

perform misha_hide_out_of_stock_in_search( $question ){
    if( is_page( array( 5576, 6489, 2 ) ) )  {
        $query->set( 'meta_key', '_stock_status' );
        $query->set( 'meta_value', 'instock' );
    }
}

It really works very nicely however for one purpose within the pages that i apply the code my header menu disappears and i do not know why. I already know that the issue is within the code as a result of when i disguise the code my header menu seems once more.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments