Order by & include array by specific post ids

use post__in key instead of include to get posts from the specific post ids. $args = array( ‘post_type’ => ‘testimonials’, ‘posts_per_page’ => 4, ‘orderby’ => ‘ID’, ‘post__in’ => array(883, 563, 568, 106), ); And to order posts by the given posts ids, you can use the following array. $args = array( ‘post_type’ => ‘testimonials’, ‘posts_per_page’ … Read more

How to filter custom posts by tags and custom fields?

you can use custom taxonomies and make you query_posts much easier! by that i mean create a custom taxonomy for type,duration like so: add_action(‘init’,’register_event_tax’); function register_event_tax(){ register_taxonomy(‘even_type’,array(‘events’), array( ‘hierarchical’ => false, ‘labels’ => ‘type’, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘type’ ), )); register_taxonomy(‘even_duration’,array(‘events’), array( ‘hierarchical’ => false, ‘labels’ => … Read more

Display/query post formats

You have a lot of options for displaying using the “Post Formats” feature: for example in an index.php loop you can decide what to show based on the post format using has_post_format() function : if ( has_post_format( ‘aside’ )) { echo the_content(); } elseif ( has_post_format( ‘chat’ )) { echo ‘<h3>’; echo the_title(); echo ‘</h3>’; … Read more

Fail to compare dates in meta_query

I have exact the same problem here, except i use the std. post type (post) and a category in my query. everything works except the sort order. $d = date(“Y-m-d”); $args = array( ‘post_type’ => ‘post’, ‘category_name’ => ‘events’, ‘post_status’ => ‘publish,draft,pending,future,private’, // just for me ‘meta_key’ => ‘event_start’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, … Read more

Query posts by custom taxonomy ID

The reason this isn’t working is because ‘tax_query’ needs to be an array of arrays (confusing, I know). … ‘tax_query’ => array( array( ‘taxonomy’ => ‘build-type’, … It is that way so you can group a few different rules together.

How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?

Hopefully you’ve figured this out by now, but if you haven’t you should be able to use the “posts_orderby” filter to dial in a specific order for your query. I’m not going to give a full solution here, but you can refer to this post for more: http://mitcho.com/blog/how-to/external-orders-in-wordpress-queries/ EDIT: Here’s the Documentation – basically you … Read more

WP_Query vs get_posts

The difference between get_posts & WP_Query You can view get_posts() as a slimmed down WP_Query. In fact looking at the source: //… prepares query array $r $get_posts = new WP_Query; return $get_posts->query($r); get_posts() use WP_Query, but only returns an array of posts – nothing more. Furthermore it sets: $r[‘no_found_rows’] = true; Normally (by default with … Read more

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