Interference of a code with a web story
-
Hello, I use the following code that I found on the internet to move non-existent products to the bottom of the page and display the products in order of publication date, and it works correctly. But after installing the web story plugin and trying to create a story in product categories, I realized that this code causes the story not to be displayed. It means that the web story does not work in the pages where my product list is displayed.
Please help me in this problem/** Show Out of stock products at the end in Woocommerce */ add_filter('posts_clauses', 'order_by_stock_status'); function order_by_stock_status($posts_clauses) { global $wpdb; // only change query on WooCommerce loops if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) { $posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) "; $posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby']; $posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where']; } return $posts_clauses; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Interference of a code with a web story’ is closed to new replies.