Code-Snippets-Functions/Execute a function on a child site/WooCommerce/hide-private-products-shop.txt

7 lines
295 B
Text

add_filter( 'posts_where', 'bbloomer_no_private_products_posts_frontend_administrator' );
function bbloomer_no_private_products_posts_frontend_administrator( $where ) {
if ( is_admin() ) return $where;
global $wpdb;
return " $where AND {$wpdb->posts}.post_status != 'private' ";
}