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

Display child posts from a certain category

You can use the post_parent argument for the query. Here is a slightly modified version of your code: <ul class=”podcasts”> <?php global $post; $catquery = new WP_Query( ‘cat=7&posts_per_page=30&order=DESC&post_parent=” . $post->ID ); while($catquery->have_posts()) : $catquery->the_post();?> <li class=”track-list-item”><?php the_content();?></li> <?php endwhile; wp_reset_postdata(); ?> </ul>