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

0
votes
2answers
135 views

comment meta_query for keys that aren't yet set

I need query help! I am trying to set up a meta_query (for get_comments) for keys that aren't yet set. I have some code that allows moderators to add a custom meta key to individual comments. Click ...
0
votes
1answer
114 views

Meta Query for specific months

I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm ...
0
votes
0answers
65 views

Meta query “OR” comparison not working as expected with array

I have this code to get cars that have color 1 or 0 ( stored in db in rw_color as 1 for white and 0 is black): $args_search = array( 'post_type' => array( 'cars' ), ...
0
votes
2answers
61 views

meta_query compare not doing what I want it to do

I'm trying to run a query that only shows posts if it's meta value has a date string that is LESS than the current date's string. An example is below; <?php $current = date('Ymd'); // Eg: ...
0
votes
1answer
135 views

latitude/longitude meta_query

I've been trying to figure out a way to do radius search in WP and decided upon a simpler way than big queries, I'm having problems returning results though I've got a function called ...
0
votes
1answer
33 views

How to output meta_key in wp_postmeta?

I have a meta_key in wp_postmeta called _su_description. How do I output its value?
0
votes
1answer
309 views

Can't sort order of wp_query with 2 meta keys

I'm trying to display custom post types by excluding the sold ones but also by displaying them in alphabetical order from the county meta_key. I'm trying to use pre_get_posts but I'm not sure that ...
0
votes
1answer
2k views

exclude custom post type by meta key in wp_query

I'm trying to display a custom post type (properties) and exclude posts that have a certain meta value (sold). Is there a way that I can do this? I have this for my code so far: ...
0
votes
1answer
131 views

Ordering a mysql style datetime stamp with meta_query

I have a custom post type field that I am storing data in called football_game_datetime. Example format and values for this field are examples like: "2013-10-31 14:00:00", "2013-09-16 20:00:00", ...
0
votes
1answer
1k views

meta_query with array as value with multiple arrays

Already got some clues on how to do this, see here: meta_query with array as value but i am confused over multiple meta_queries like this: for ($i=0; $i< count($amenities); $i++) { ...
2
votes
1answer
165 views

Exporting Data from WordPress into a flat table

I need to be able to export the data within WordPress so that each object is contained in a single row, like a flat table. Imagine each post type as it's own database table, containing columns that ...
1
vote
1answer
471 views

How do I create my own nested meta_query using posts_where / posts_join?

Some of my posts (not all) have a price as a meta key/value. Today I use the pre_get_posts action so that my users can search for prices that are between a certain value. This is the code that I'm ...
0
votes
1answer
309 views

Creating arguments from loop for WP_Query meta_query

I'm trying to create a WP_Query with the outcome arguments such as: $args = array( 'post_type' => array( 'post', 'custom' ), 'meta_query' => array( 'relation' => 'AND', ...
1
vote
0answers
94 views

Possible to filter custom post type with multiple meta data?

I'm wondering if it's possible in one loop to accomplish what I need to do. What I would like is to sort all custom post types by the meta data of county and put them in order which it is doing here. ...
0
votes
1answer
162 views

Looking for a way to exclude frontpage and nav menu from query filter

maybe I'm thinking about this the wrong way, but I need to: A) exclude posts in queries site-wide (minus frontpage and navbar) based on a comparison with a meta_value, and B) orderby a differnt ...
0
votes
0answers
18 views

Query posts than have a lapse of time active

First of all, sorry guys for my poor english. OK, i wanna make a query for show posts that doesn´t passed 3 days from it publication. I set a field for the expire date when it´s published (the time is ...
0
votes
1answer
487 views

Why doesn't my WP Meta Query return any results?

Is it not OK to accept a value from $_GET as the key in a WP Meta Query? I'm not sure why this code doesn't return any results... BOTH the queries for Price as well as bedrooms do not return any ...
0
votes
1answer
114 views

Ordering by multiple meta keys - Custom post type

I've searched the web to try and do this but none of the examples quite resemble the way my data is currently laid out, I wonder if someone can tell me how to tailor it to my setup? This is the way ...
2
votes
2answers
1k views

Custom query variable - get wordpress to redirect to nice permalink url

I have been looking for an answer for the last couple of hours but could not find anything pointing me in the right direction. Some advice would be very much appreciated! What I already have: A ...
1
vote
1answer
406 views

Query multiple meta values

I'm working on a 'checkbox filter' to query posts by checked values. See this link (EDIT: As you can see there are just 2 posts in this link, as soon as the user checks for 'MINI' it gets a good ...
0
votes
2answers
599 views

Query based on custom fields start and end date

I have a custom post type called Events, with 2 custom fields, start date and end date. These fields are stored using a timestamp in the database. I want to create a custom query based on these 2 ...
0
votes
2answers
529 views

Event with multiple dates, display events chronologically

I've been breaking my head over this for days now and can't seem to figure it out (with the limited knowledge I have). I want to achieve the following: I have a custom post type 'Events'. Each event ...
0
votes
1answer
53 views

Meta_query not filtering posts

I'm trying to filter out 'properties' on a page based on whether they are vacation or long-term rentals. Right now, the results of the following query displays all properties, not just either vacation ...
1
vote
1answer
98 views

Get posts between custom dates

I created an event CPT and a meta box with a date. I saved the date as post_meta in the form dd.mm.yyyy. Now I want to create a shortcode that queries all posts which's dates meet the condition ...
0
votes
1answer
430 views

Get a single post ID based on an exact match of 1 or more meta values

I'd like to find the post ID based on an exact match of meta values (could be more than 1). All the examples I have found show find the post ID from 1 meta value. In my example I'd like to pass in an ...
1
vote
1answer
322 views

Query for custom post type objects in a taxonomy and with a meta value

I want fetch all posts from the post type book in the custom taxonomy book_tags with the meta key lang and the meta value en. My code: <?php $args = array( 'post_type' => 'book', ...
0
votes
2answers
168 views

Query posts by searching for a string in a meta field

I'm trying to see if I can make this happen with the built-in meta_query function. I'm taking a $_GET variable and want to return posts that contain that string inside the meta_key urls. So far, the ...
0
votes
1answer
99 views

wp_Query with 4 post meta feald arguments gives 500 internal server error

I am creating a custom plugin to search for custom post type provided with 4 meta field arguments. I am using wp_Query() to fetch the search results. My Query string is. $args = array( ...
3
votes
2answers
267 views

Search multiple meta keys at once

How would I modify the following SQL Query to allow me to search multiple meta keys at once? e.g. user_business AND user_about In the end I'll be searching about 40 - 50 different meta keys; or if ...
0
votes
2answers
477 views

order by meta_key [duplicate]

i have a little problem: I can not order my events as i wish. I would like to order my upcoming events in ascending order... I am using the following: new WP_Query( array( 'author' ...
0
votes
3answers
197 views

Filtering all posts AND sticky posts through meta_query

I have a filter that filters posts from the main loop depending on a user role (handled externally) The meta data is entered when adding a post/page. This is the filter - it works for filtering ...
0
votes
1answer
67 views

WordPress Mysql query and Duplicate

i've a problem with mysql query on my wordpress database. I've custom fields Country and City. At moment I have this query that show all the cities of "UK" Country $querystr = " SELECT wposts.* ...
0
votes
1answer
151 views

Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months

I have a post type that holds a custom meta field with a date in it. The date is stored in the format: yyyymmdd. On the archive page for this post type I want to create 12 separate containers, one ...
0
votes
3answers
814 views

Undefined property: WP_Query::$post

I am working on some rather elaborate comparisons between metadata and having a bit of trouble correctly referring to results from my query. The first query to establish $team_is_home works fine but ...
2
votes
2answers
957 views

Sorting: custom query with orderby meta_value_num THEN by title

i try to run a custom post type query to match following criteria: sort movies first by year in descending order, after that ("inside" the year order) by title alphabetically. desired output: ...
3
votes
2answers
325 views

Best practice - Meta Query vs. post_clauses for “left join” ordering

Moreso a psuedo-code question than actual code. I have some custom post meta attached to attachments, and created a list table column for this meta. The meta is either 1, or null (not set), but I am ...
2
votes
2answers
5k views

Get posts based on meta key/value

I have a custom post type "custom_author" which is selected when making a new post using a metabox dropdown with field key "chosen_author". This is what my wp_postmeta looks like: Where 13088 is ...
0
votes
1answer
279 views

WordPress Meta Query: Relation is not working correctly

I make a custom search box and let user do search. I have added required field to my editing panel by custom meta box. I have a post which have some meta data like London as place and 13021 as post ...
1
vote
2answers
597 views

Optional Meta Query

I have places stored as posts in WP's posts table. I am doing some geo-locating using Geo Data Store (http://wordpress.org/plugins/geo-data-store/). This is working great for me, as I can currently ...
2
votes
1answer
664 views

Query by meta_key and order by meta_value_num return orderby date

I'm trying to use the orderby and custom WP_Query features of wordpress. It works nicely to select item by their meta and to order by date. Unfortunately, it seems that I could not get the post ...
0
votes
1answer
585 views

WP_Query with several meta_query-statements and order by meta_value

This is my query: $the_query = new WP_Query( array ( 'post_type' => 'pass', 'posts_per_page' => '-1', 'post_status' => 'publish', ...
0
votes
0answers
13 views

paginate_links with meta_query showing incorrect number of pages [duplicate]

I seem to be having a strange problem with paginate_links, and I'm hoping someone can help. I have a custom post type for events, events have categories and a custom field for start date and end date. ...
1
vote
0answers
68 views

database query with more than a couple meta hangs and doesn't complete

I have a development website with about 70 checkboxes for custom fields. The idea is the user selects one or more checkboxes, it queries the database for all posts that have a meta_key for the ...
0
votes
1answer
485 views

Query posts by Author and/or by Tag

I'm pretty sure I need to do some sort of custom query, but not sure about the best way to go with it. I have an author page. It needs to display that author's posts. That's fine, I can do that. I ...
0
votes
1answer
1k views

filter search result with custom post type meta key

The default search returns all post types, which is what I want. But for one specific custom post type I want to limit the result to a specific meta key value (a custom date that must be greater than ...
0
votes
0answers
159 views

Search with meta_query and tax_query

I'm working on a little database for series based on wordpress. I've implemented a custom post type called "anime", some taxonomies (Genre, a_types..) and a lof of customfields. (based on acf). Now ...
2
votes
1answer
588 views

Perform query with meta_value date

I am trying to perform a query on a custom-type post using the value of a custom field. This field contains a string date: dd.mm.yyyy. The post type name is 'event' The custom field name is ...
0
votes
1answer
1k views

Filtering a WP_Query meta_query by numeric values isn't working

That was a very dense title. I have a custom post type "event" which has a Date/Time picker field "event_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX ...
1
vote
1answer
251 views

Mysql query and order meta value

I made a mysql query to WordPress like this: $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND ...
1
vote
1answer
153 views

Change order of posts

I made a post recently that did not explained myself right! Come again, but with better explanations. I need the "Select Option" change the order of query_posts. My current code is: <select> ...