Query custom meta value – post view and date meta

@Sadia Please, try this once:: $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘3’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘post_view’,// say 200 ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DSC’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘post_view_last’,//2017-04-14 ‘value’ => date(‘Y-m-d’, strtotime(‘-7 days’)), //value of “order-date” custom field ‘compare’ => ‘>=’, //show post less than … Read more

wp_query sorting – one specific meta_key value at last and then sort by create date

If you’re using WordPress 4.2 or newer then you can do the following: $args = array( ‘post_type’ => ‘products’, ‘posts_per_page’ => 10, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘tools_clause’ => array( ‘key’ => ‘tools’, ‘compare’ => ‘EXISTS’, ), ‘create_date_clause’ => array( ‘key’ => ‘create_date’, ‘compare’ => ‘EXISTS’, ), ), ‘order_by’ => array( ‘create_date_clause’ => ‘ASC’, … Read more

Why is my query not giving results?

Thanks for comments, It has been fixed by replacing ‘type’ => ‘DATE’ with ‘type’ => ‘NUMERIC’ I hope this will be helpfull. I adding link where I finded my answer https://gist.github.com/billerickson/3698476#file-gistfile1-php

WP query retrieve the src of attached image

You can use wp_get_attachment_image_src and get your desired sized image and then pass onto your array : foreach( $posts as $post ) { $imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), “medium” ); $imgsrc = $imgsrc[0]; $output[] = array( ‘id’ => $post->ID, ‘title’ => $post->post_title, ‘count’ => $post->custom_total_hits, ‘soundcloud_url’ => $post->soundcloud_song, ‘soundcloud_id’ => $post->soundcloud_ids, ‘link’ => get_permalink($post), ‘image_src’ => … Read more