posts_clauses drop ACF get_field function
-
Hello
I try to use function for order by stock status in my store catalog but this code drop ACF get_field() function
when function on, get_field return only ID of post (https://skr.sh/sGyfgZ3GwaP)
and when function off, all right, get_field return array (https://skr.sh/sGyHPC9UUOw)
please help me to find a reasonadd_filter( 'posts_clauses', 'order_by_stock_status', 2000 ); function order_by_stock_status( $posts_clauses ) { global $wpdb; 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; }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘posts_clauses drop ACF get_field function’ is closed to new replies.