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

1
vote
1answer
494 views

Filtering by Post Meta Custom Fields - Performance

I could use some advise on how to structure my data for performance. I have a custom post type with a lot of custom meta data stored in the wp_postmeta table as a serialized array under one meta key ...
1
vote
2answers
42 views

Query that joins the postmeta table twice

I believe what I'm trying to do is too complex for the standard meta_query parameter in get_posts, so I'm trying to use a custom SQL query to do the following: I have a game custom post that has ...
1
vote
1answer
378 views

How can I combine meta_query queries?

I'm trying to build combined meta_query queries but they don't work. Any ideas how I can implement queries like the example below? Thanks, Hinnerk Array ( [relation] => AND [0] => ...
1
vote
1answer
1k views

Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that

I have a WordPress blog that is all user based Authors that submit content and such. Currently in the site, you can view other authors profiles but basically just view their content from the ...
1
vote
2answers
590 views

Nested Queries using meta_query

I'm trying to build a query that lists posts of a custom type with specific custom field values. Then I need to list children of each of those posts within the post, and those children also need to be ...
1
vote
2answers
905 views

meta_query, number comparison, not quite working as it should

I have a wp_query that gets all custom post types in ascending order from today, to list some events on a site of mine. While this works fine: $args = array( 'post_type' => 'events', ...
1
vote
1answer
906 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 ...
1
vote
1answer
144 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
1
vote
3answers
613 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 ...
1
vote
1answer
134 views

Possible to create a permalink to sort with meta_key?

I feel like I've been all around the web and back again looking for an answer to this and it's really starting to grind my gears. Not sure if this is the correct way to do it, but I want to add a ...
1
vote
1answer
45 views

meta_query keys and sticky posts

The problem is that the code works but when i make a post sticky it doesn't appear at first. The function of the code: It only shows posts that have a thumbnail or a slideshow image. <?php $args ...
1
vote
3answers
132 views

Searching by meta values showing inappropriate result

I am working on a custom search by meta value and using this: print_r($_REQUEST); $args = array( 'post_type' => 'property_post', 'posts_per_page' => 10, 'order' => 'ASC', ...
1
vote
2answers
3k 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 ...
1
vote
1answer
2k views

wordpress get meta value by meta key

How to get the meta value by meta key I want to get the value by the meta key. This is what I have tried so far: $args = array( 'post_type' => 'post', 'post_status' => 'publish', ...
1
vote
1answer
137 views

How to stop wp_postmeta from being called on archive and search pages?

Currently, when I load a search or result page, it queries the wp_postmeta table which is leading to the page taking ages to load. I realise this is a result of this table being huge (70k rows), and ...
1
vote
1answer
400 views

WP_Query filter and order by meta ordering by wrong joined table

I'm trying to both filter and order a Wordpress query using the meta_value, however the ORDER BY part of the query seems to be working on the wrong table. The query params here are: array(12) { ...
1
vote
1answer
1k views

WP_Query last five posts, simply ordered by meta_value

I can't believe I'm asking this question. It feels like such a simple method, yet I've poured over the WP pages and dozens of similar questions to no avail, so here it is... I've got a WP_Query with ...
1
vote
1answer
330 views

Pull a post based on a meta value in a custom post type

I'm trying to display a post, from a custom post type based on a meta value in that post type, in this case a checkbox that says "if this is checked show it on the front page. Usually I write a ...
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', // ...
1
vote
2answers
53 views

Single meta_query query using OR instead of AND in request's WHERE statement

I want the native WordPress search input to search metadata in addition to its standard title and content search, however setting a meta_query adds an AND clause to the request when what I need is an ...
1
vote
1answer
49 views

How to implement custom search with input fields?

I want to implement a search form like this: Loan Form In my theme I have a custom post type called Data with the Year and Money custom fields. I googled a lot but can't find a way to submit the ...
1
vote
1answer
164 views

WP_Query using meta_query with relation OR and orderby meta_value doesn't work

I've been bashing against a bug for a few hours now, and can't seem to find my error. Could there be a bug with the relation type 'OR' in WordPress? $evenements = new WP_Query(array( 'post_type' ...
1
vote
1answer
85 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 ...
1
vote
2answers
552 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 ...
1
vote
1answer
172 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
310 views

How to add a new meta key and assign timestamp to posts

I've been trying to look for a way to create a loop in my website and show posts being read/watched but have not found anything. The only way I can accomplish this would be to create a new meta key ...
1
vote
1answer
476 views

Using OR in WP_Query negates the “NOT EXISTS” compare

I'm attempting to filter posts by a custom field that either are equal to 'new' or have not been set yet. I'm able to get either of those meta_queries to work on their own but when I use them in an ...
1
vote
1answer
111 views

Get content from pages with same meta_key from Database

I need help! I'm doing this template page and I want to get content from pages with the same meta_key. I want to display all pages thumbnails that has the value "red" in the meta_key. The problem is ...
1
vote
1answer
232 views

meta_value_num sort glitch

i have a custom query, and I have a meta key that contains a sequence number: 1.1, 1.2, 2.1, 2.2... 11.1, etc the problem occurs when the numerical sequence gets in to double digits, ie. 5.11, 5.12, ...
1
vote
1answer
300 views

Filter posts with meta_query NOT IN where value has multiple values

I would like to use a meta_key to store multiple values in that key. Thereafter, I would like to filter away posts that do not contain a specific value in the key. In other words, just show posts ...
1
vote
1answer
395 views

Meta_query with or without value

I am using WP_Query to sorting the post by user input. The input contains meta value which is display in select type field. Normally when there is value inserted into the form, the wp_query working ...
1
vote
1answer
138 views

Query by multiple meta elements not seeming to work - wordpress is timing out

Trying to run a query that pulls: get me 4 posts or pages that are not in sticky_posts and have (my_featured_post = 1 AND photo-image_post_id > 0) OR (my_featured_post = 1 AND photo-image_page_id ...
1
vote
2answers
1k views

Using Query Posts With Multiple Post Types And A Taxonomy

I am developing a site that has two different custom post types; one of them is called Articles and one is called Sketchpad. Sketchpad is user submitted content that is assigned a custom taxonomy term ...
1
vote
2answers
1k views

How do I make a meta_query OR relation work? [closed]

Here's are wp_query args: $args = array( 'post_type' => 'sportpages' ,'post_status' => 'publish' ,'posts_per_page' => 1000 ,'post_parent' => 4738 ,'meta_query' => ...
1
vote
1answer
2k views

How to grab metabox value in wp_query meta_query key

How would I modify my WP_Query in order to get a custom meta box value instead of a custom field one like I currently do? This is how my query looks like: <?php $today = ...
1
vote
2answers
954 views

Orderby custom field meta value ASC and then by date DESC

I need to allow post ordering in certain categories. One of the sorting options is a custom field meta value. First problem is that not all posts have that meta assigned and i need to order these by ...
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 ...
1
vote
0answers
28 views

Get specific repeater row (via advanced custom fields) based on Meta Query with Wildcards

I've used Example 5 of: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/ to query a post by a wildcard. However, my problem is I only want to ...
1
vote
0answers
48 views

Configuring a meta query with multiple post types that have the same relationship on a single page

I am creating a client portal were my clients can maintain their projects and leave feedback. I have two custom post types called "Clients" and "Projects" and they each pull information from one ...
1
vote
1answer
61 views

How to Output which matched meta_keys were found from custom_type_posts?

In WordPress on the single-player.php page which displays a single profile (from numerous other profiles) with information from around 10 different meta fields. Without using tags or categories.. ...
1
vote
1answer
38 views

Permalink structure with $_SESSION variables

I have a project that has content being filtered throughout the site (many custom WP_QUERY calls). Originally there was no URL needs, just filtering by $_SESSION variable. Works perfectly, but NOW ...
1
vote
0answers
23 views

2 weeks ago from meta query meta value

This is my meta query within my posts query. 'meta_query' => array( array( 'key' => 'rw_membership_ends', 'value' => ??????? ...
1
vote
2answers
95 views

meta_query compare='!=' with multiple custom fields

a post has the following custom fields: 'my_custom_field' => 1 'my_custom_field' => 2 'my_custom_field' => 3 I now want to query all posts that do NOT contain the value 2 for ...
1
vote
0answers
116 views

WP_Query with meta_query dosen't return results

I am trying to get list of posts filtered by fields I added using the advance custom fields plugin. I have more fields that I want to use but it doesn't work as I want it to. Here is what the query ...
1
vote
2answers
124 views

WordPress Core - Optimizing meta_query generated SQL?

I have a problem in a plugin of mine which uses post meta to store ownership of a post. Basically, my issue is that the WP_Meta_Query class generates one JOIN per meta_query query. I don't understand ...
1
vote
1answer
317 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 ...
1
vote
0answers
86 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. ...
1
vote
1answer
206 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', ...
1
vote
1answer
470 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 ...
1
vote
0answers
62 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 ...