Tagged Questions

Refers to a mechanism built into the WP_Query class for querying the database for post data, including pages and CPTs, based upon post meta data.

learn more… | top users | synonyms

7
votes
1answer
9k views

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

I've been troubleshooting an issue over the past few days and keep going in circles. Could really use a fresh pair of eyes to help me answer this question... So I'm working with a wordpress site ...
0
votes
2answers
308 views

WordPress & MySQL , problem with use many array in meta_query

I use this code for display custom posts : $args = array( 'category__in' => $bookcat, 'meta_query' => array( 'relation' => 'OR', array('key' => ...
1
vote
1answer
1k views

I can't set meta_key in my custom post type query

I've created a custom post, events, and saved the meta data event_year to each event. I'm trying to get a year's event archive. When I go the the following URL, the meta_key and meta_value are not ...
3
votes
1answer
2k views

WP_Query with checkbox meta_query

I have posted this on StackOverflow too, not sure if that's allowed - if not let me know and I'll remove one (I don't want to look like I'm spamming). Anyway.... I have a custom post type and have ...
0
votes
2answers
655 views

meta queries do 'either/or' checks

I have a meta_query like this , but 'relation' => 'OR' NOT WORKING, Does meta_query only do 'both/and' checks and don't do 'either/or' ? $args = array( 'post_type' => 'post', 'posts_per_page' ...
5
votes
1answer
768 views

how to show posts that are missing a meta_value

How can I build a query to find posts that DO NOT contain a certain meta key or meta value? for example: query_posts( array( 'meta_query' => array( array( 'key' => 'feature', ...
5
votes
1answer
5k views

Using meta_query, how can i filter by a custom field and order by another one?

With the following code (in functions.php) my posts (of CPT event) are ordered by _end_date instead of _start_date. What's the proper solution to this as of WP 3.1.3? Of course I'd like to avoid using ...
1
vote
1answer
3k views

How to create a wp_query that contains both meta_query and tax_query

I have a wp_query that works great but I can't have both a meta query and a tax_query in it. <?php $event_query = new WP_Query( array( 'post_type' => 'event', // ...
3
votes
3answers
2k views

querying with custom meta field with meta_query

How do we get posts where the meta key does not exist in a post. I have created a meta_key video. and i want to be able to get some posts with WP_Query where custom field video does not exist or is ...
0
votes
1answer
686 views

What's missing in this wp_query and meta_query

There is something missing because this is driving me crazy at the moment. I'm using the wp_query with the following args. $args = array( 'post_type' => 'project', 'post_status' ...
4
votes
4answers
5k views

Fail to compare dates in meta_query

This is the piece of code I use to get event posts whom date metadata is newer than today : <?php query_posts( array( 'post_type' => 'concerts', 'meta_key' => ...
1
vote
1answer
155 views

Custom query with DECIMAL(5,2)

I want to know if there is a way to DECIMAL (5,2) instead of DECIMAL in meta_query
0
votes
1answer
188 views

How to “orderby” the first array in a meta_query that uses multiply keys?

My query is currently sorting by end date. How can I make it so it will sort by the start date? $args = array ('post_type' => 'events', 'meta_query' => array( ...
1
vote
1answer
2k views

WP 3.1 meta_query for multiple custom field values

I'm trying to use some conditional logic to compare custom fields in my query, but a bit stuck. How would I get all posts with ReleasedProject AND PermanentArtist set to 'true'? Here's what I have so ...
12
votes
6answers
10k views

meta_query with meta values as serialize arrays

I'm working on a project in which I'm creating a custom post type and custom data entered via meta boxes associated with my custom post type. For whatever reason I decided to code the meta boxes in ...
1
vote
3answers
626 views

Get Posts shortcode plugin and meta_query?

I'm using Get Posts plugin to list posts with post type "project". I want to filter the list by two custom fields: year (ex. 2006) and state (ex. Completed). I added meta_query to the plugin's ...