Tax_query terms ID’s using variable

It looks like you are making an array with a single string inside. Check if making $tax into an array before passing it will work: $tax = array( 19, 18, 214, 226, 20 ); $query_args = array ( ‘post_type’ => ‘works’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘materials’, ‘field’ => ‘term_id’, ‘terms’ => $tax, ) … Read more

get_template_part in for loop

Your problem is that the variable passed to setup_postdata() must be the global $post variable, like this: // Reference global $post variable. global $post; // Get posts. $posts = get_posts(array( ‘post_type’ => ‘post’, ‘post_count’ => 4 )); // Set global post variable to first post. $post = $posts[0]; // Setup post data. setup_postdata( $post ); … Read more

Query WooCommerce orders where meta data does not exist

The meta_query argument (that you can use in a WP_Query) is not enabled by default when using a WC_Order_Query through wc_get_orders() WooCommerce function. But for you can use the undocumented Custom Field Parameters (just like in a WP_Query): meta_key meta_value meta_value_num meta_compare So in your case you can use the following instead: $orders = wc_get_orders( … Read more

Sorting posts by custom date fields (non standard date format)

You can add a posts_orderby filter to flip the meta_value: function wpse174075_posts_orderby( $orderby, $query ) { if ( $query->get( ‘orderby’ ) != ‘ddmmyy_date_format’ ) return $orderby; if ( ! ( $order = $query->get( ‘order’ ) ) ) $order=”DESC”; global $wpdb; $mv = $wpdb->postmeta . ‘.meta_value’; // Note SUBSTR() position (2nd) arg is 1-indexed. return ‘CONCAT(SUBSTR(‘ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)