wordpress get meta value by meta key

WP_Query selects posts and not meta value that is way you are not getting the value. You can use the returned post ID to get the value something like: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 1, ‘meta_key’ => ‘picture_upload_1’ ); $dbResult = new WP_Query($args); global $post; if ($dbResult->have_posts()){ $dbResult->the_post(); $value … Read more

How to filter categories by custom field?

You should be able to use the meta_query attribute that uses WP_Meta_Query behind the scenes: $child_categories = get_categories( array( ‘parent’ => $cat_id, ‘orderby’ => ‘id’, ‘order’ => ‘DESC’, ‘hide_empty’ => ‘0’, ‘meta_query’ => array( array( ‘key’ => ‘mykey’, // Adjust to your needs! ‘value’ => ‘myvalue’, // Adjust to your needs! ‘compare’ => ‘=’, // … Read more

Query between two meta keys

Update – it may be supported in a meta_query. I need more information – see below. You can’t do it using a meta_query, it’s not supported. Do you have data in meta_data fields? – WordPress queries will exclude posts where any of the orderby (or meta_query) fields is missing. WordPress adds a join condition to … Read more

Filtering a WP_Query meta_query by numeric values isn’t working

Try an array of arrays in your meta query. $args = Array( ‘post_type’ => ‘event’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘event_date’, ‘compare’ => ‘>=’, ‘value’ => intval(strtotime(date(‘Y-m-d’))), ‘type’ => ‘numeric’ ) ), ); $query = new WP_Query( $args );

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

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