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

Display posts of the last 7 days

In addition to birgire’s solution, as of WordPress 3.7, you can use Date parameters. Your arguments would look like this to filter posts from the last 7 days: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, // Using the date_query to filter posts from last week ‘date_query’ => … Read more

how to query posts by category and tag?

Edit: See below for proper way to query category and tag intersections. global $wp_query; $args = array( ‘category__and’ => ‘category’, //must use category id for this field ‘tag__in’ => ‘post_tag’, //must use tag id for this field ‘posts_per_page’ => -1); //get all posts $posts = get_posts($args); foreach ($posts as $post) : //do stuff endforeach;

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