New answers tagged

0

$args = array( 'post_type' => 'product', 'meta_key' => 'YOUR_FIELD_ID', 'meta_value' => array('yes'), //'meta_value' => array('yes'), 'meta_compare' => 'IN' //'meta_compare' => 'NOT IN' ); $products = wc_get_products($args); foreach ($products as $product) { //do your logic }


0

Try This. $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_key' => 'ingredients', //Your Custom field name 'meta_value' => ' ', //Custom field value 'meta_compare' => '=' ); $the_query = new WP_Query( $args ); $count = $the_query->post_count; if ( $the_query->...


0

Without much luck, I solved my own problems by using get_transient(...) and set_transient(...) Note, this is a wordpress-only fix. and I still makes the first call the query the one who has to suffer. In my case, it was acceptable since I am fine with storing the result for the entire day. Even 12 hours is fine for me. I'm still looking for answers to the ...


0

Based on Can I exclude a post by meta key using pre_get_posts function? // setting meta in pre_get_posts Query all posts where a meta key does not exist // exists & not exists formatting multiple orderby in pre_get_posts action // how to set multiple ordeby you could perhaps try something like this in your pre_get_posts filter, //Get original meta ...


0

The difference is what is returned. The WPDB query() method returns true for CREATE, ALTER, TRUNCATE and DROP queries, an integer of how many results for all other queries, or simply false if if there's an error. The WPDB get_results() method actually returns the entire result of the query (like you would get running the query in phpMyAdmin). You can ...


Top 50 recent answers are included