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
27 views

WP User Query with search columns and meta query

I'm trying to build a query with WP User Query where it's possible to search after user_email user_nicename first_name last_name This are my args: $args = array( 'role' ...
0
votes
3answers
67 views

Order By Multiple Meta Fields

I have two custom fields: meta_key1 is boolean (0 or 1). meta_key2 is a date value - 20150623 for example. Not all meta_key2 fields have an explicit value. It looks like their being treated as an ...
0
votes
2answers
26 views

Orderby doesn't work like expected on custom query

I have this custom query: query_posts( array ( 'orderby' => 'rr_recommends_count', 'meta_key' => 'rr_recommends_count', 'order' => 'DESC', ) ); Which orders the posts ...
0
votes
1answer
19 views

Custom loop - Isolating post meta output depending on current query taxonomy terms

I have started constructing is a page to display a series of products based on certain criteria. Each product is part of two separate taxonomies, one for brand and one for product size (each product ...
0
votes
0answers
17 views

ACF Data Modelling issue?

I'm either missing something or there seems to me like a problem that ACF stores its relational fields as serialzied arrays. Example: I have two custom post types: Game Bonus A bonus is related ...
1
vote
1answer
847 views

Matching Serialized Arrays with meta_query

I've asked a related question previously, but I think I've finally worked out the crux of my issue. I'm using Advanced Custom Fields and have a number of custom fields attached to my post type. I'm ...
1
vote
1answer
16 views

How can I apply a meta query for a single custom post type in the main query?

I have custom post type called event, which has custom fields for start_date and end_date. For the event archive, I'm filtering out "expired" events using the following meta query added to the main ...
0
votes
0answers
10 views

WP Query - Group by relation (custom post type)

I have a custom post type Office. An office has an address, email, ... . An office also has a relation with a custom post type Region. So an Office must have a relation with a relation with one ...
1
vote
1answer
787 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
1answer
557 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
1answer
340 views

Very slow query with meta_query on large database

I have a blog with about 200k posts and each one have 20 custom fields. I've been using WordPress Transients_API to cache queries, in the few cases where it can be used, but it can't be used in some ...
0
votes
1answer
26 views

Query Custom post type with Taxonomy Custom Field

I have a Taxonomy called Cities. I have created a custom field for this taxonomy, using ACF, called Country So I can create a City and select the Country (select list with predefined options) it ...
2
votes
2answers
3k views

Sort Posts by Multiple Meta Values [duplicate]

1) Custom Post Type named "Buying_Locations" 2) Each Post has three meta values of: State, City, Store Name QUESTION: How can you show a list of these posts sorted alphabetically by State, then ...
0
votes
2answers
2k views

How can I create a meta_query with an array as meta_field?

Here are the args for my query : $args = array( 'post_type' => 'news', 'meta_query' => array( array( 'key' => 'topics', 'value' => 'sports', ...
0
votes
1answer
1k views

Displaying Metabox value (custom post type taxonomy)

I have been stuck on this for days, reading articles and articles and nothing works. I am trying to display the value of my metabox on a template page. I successfully added the metabox, and I see ...
7
votes
3answers
5k views

Using meta query ('meta_query') with a search query ('s')

Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field. My current query: $args = array( 'post_type' => 'post', 's' => $query, ...
0
votes
1answer
22 views

Querying by taxonomy vs Querying by Custom fields Speed Comparison

I'm developing a listing portfolio for our project. (Basicaly yachts with their type, size, price, cabins, draft, build year, refit year etc.) I should filter them according to type and sort by ...
0
votes
1answer
124 views

WP_Meta_Query object with conditionals

I have a custom post type (Books) that is connected with a second custom post type (People). The Books CPT has an additional author meta box that if checked, it should appear on the additional People ...
1
vote
1answer
81 views

advanced search forms with 3 input text and that the main problem 3 input text

N.B. : all my work is on wordpress. I was working for an advanced form with 3 input text in purpose to show a list of hotels. The problem is i tried an infinity tricks and functions but without any ...
0
votes
3answers
48 views

loop query exclude meta_key with meta_value

Hi I use a loop like this: // show all active coupons for this store and setup pagination $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => ...
1
vote
1answer
414 views

Filtering custom post type on a combination of custom taxonomies and custom fields?

I have a custom post type "artist". It has an associated custom taxonomy "artist_type" with terms "voice", "actor", "corporate" An "artist" also has custom fields for gender, location, agerangefrom ...
0
votes
2answers
2k views

Display products from specific category in shop page

I know many people asked for this question but I didn't find a proper way to do it. How to add a simple meta_query (product_cat) before the execution of the shop page's query. Maybe by using a filter ...
0
votes
2answers
23 views

Compare meta key separation

I have a meta key called $availability that can have one of four options but also multiple values separated by pipe: |. For example the value could be: severaltimes_week|oncetwice_month|occasionally. ...
1
vote
0answers
48 views

Slow WP_Query with 'OR' on meta_query

Essentially, I'm trying to query using a filter for the args being fed into WP_Query() like so: public function filter_wp_query( $args, $template_slug ) { $args['post_type'] = ...
0
votes
0answers
22 views

Modifying default search by including the users additionally

I'm taking products from a CPT with a custom field company defining Users from User Role 'company'. So, products that are filled with that particular custom field, are connected with the user account ...
0
votes
0answers
26 views

How to orderby my custom post type with two custom meta keys

I am working on real state property website. I have CPT "soto_property". I also have two custom fields for this CPT named "price" and "dorm_room". I have a search form, from where visitor can filter ...
1
vote
0answers
44 views

Meta Queries - should nesting work after WP 4.1?

I have a rather huge meta_query here and it hangs at execution: browser just won't load the page, it goes on loading ... As far as I know this should work after WP 4.1 (I have it). Also tried ...
0
votes
1answer
22 views

meta_query date and time comparisons

I am trying to query my posts against the value of 2 custom meta_keys... '_mdjm_event_date' formatted as Y-M-D (2015-05-13) '_mdjm_event_finish' formatted as H:i:s (23:35:00) Here is my query... ...
4
votes
2answers
109 views

Query Multiple Post types each with own meta query

I have 2 post types: lets say products and product_variations. I'd like to be able to modify the query via pre_get_posts to get all product with meta_keys "_visible" = "true" and "_available" = "true" ...
2
votes
0answers
61 views

Custom WP_Query order by post_meta and (author) user_meta

I am having an issue that i couldn't find on google and elsewhere. To put problem in the context. I am making a wordpress site where user can put their tutor listing for giving a tutorials, and i am ...
8
votes
1answer
10k 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
0answers
36 views

Meta query compare timestamp if exists

I have a custom post type with a start and end date timestamp. These fields are not required so they may not exist. What I want to do is query and show all posts that don't have the end date set or ...
0
votes
1answer
31 views

Searching for meta_key returns 0 posts

I am currently on a client project and I am stuck with the meta_key search in WP_Query. I am querying some other parts of the homepage successfully with the WP_Query class, but when I am passing ...
0
votes
0answers
23 views

Multiple Meta_Query using an array to search

I've got the following code from a previous developer which searches through a meta_key called new_location to match a location ID to a meta_value. It works fine for up to 3 different locations at ...
0
votes
1answer
41 views

What format does the meta_query TIME type require?

As per title - what format does the TIME type in a meta_query require? I have a couple of custom fields, date and time - the aim is to show posts dated today and in the future up to the hour before ...
0
votes
2answers
100 views

Ignore sticky posts if post is not in meta query

I have such a wp query args: $args = array( 'post_type'=> 'myposttype', 'posts_per_page' => 10, 'meta_query' => array( 'relation' => 'AND', array('key' => ...
0
votes
2answers
73 views

get_post_meta as a list for drop down search filter

I was wondering if someone could help me out. I would like to create a dropdown search filter for my wordpress site. I would like the drop downs to be populated by meta_boxes values which i have for a ...
0
votes
1answer
121 views

WP JSON API meta_query not working

In the code example below I'm using the the post title (name) as the field to store the email address while the password is in a custom field. The following query will pull the correct user but it ...
0
votes
0answers
29 views

How to use meta query for greater than value in array?

I have saved some price values of three products in a custom field name roomprice. Meta keys and values are like here: **product first** post_id = 1432 meta_key = roomprice meta_value = ...
1
vote
1answer
124 views

Any number in meta key (wp query)

I have such a query. The field modules_%_text is advanced custom fields flexible field where % should stand for ANY ROW number, it seams that it should work like that, however it's not. What i'm doing ...
4
votes
1answer
157 views

Is it possible to orderby multiple meta_keys when using meta_value_num?

Reading through the order & orderby documentation, it's not clear to me whether there is any support to order based on multiple meta_key values. Obviously, using meta_query I can return posts ...
0
votes
0answers
22 views

how to insert post in wordpress with meta

How can I get the data from a table into the wordpress posts? I use this code but not corectly works... if (isset($_GET['SQL'])){ global $wpdb; $num; $rows = $wpdb->get_results("SELECT * from ...
0
votes
1answer
1k views

WP_query - Filter by tax_query and meta_query using multiple select

I have a Publications Post Type, a Writers Taxonomy and a Publications Custom 'Meta Box' Value; parent_id. In my archive-publictions-post.php template I am trying to filter the WP_Query Class, with ...
15
votes
8answers
15k 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
1answer
45 views

Sanitize Custom Field Value in Meta Query

I'm using the pre_get_posts hook with meta_query args to filter an archive loop by dates. Basically, there is a custom post type of "events", and my users type in a date as a custom field for the ...
0
votes
3answers
1k views

How to query posts based on lat-lng coordinate as post meta?

I'm planning a custom WordPress theme where the Custom Post Type (CPT) will have latitude and longitude coordinate as it's meta value. The latitude and longitude will be displayed as a Marker in a ...
0
votes
0answers
25 views

WP search in metadata post

In want to search by meta data value in post but I didn't succes. For example if I type "sound" I want to found "sounddiary" for example. Here my code: function custom_search_query( $query ) { ...
1
vote
1answer
152 views

meta_query 'compare' => 'IN' not working

First of all, I know it's a duplicate. But, I could find those older answers helpful. I'm searching in posts through post_meta. Here's My Code: $args = array( 'numberposts' => -1, ...
0
votes
1answer
148 views

WordPress meta_query not working

I am having issues with a meta query on a custom post type. The following arguments are set: $args = array( 'post_type' => 'wp_comp_entries', 'posts_per_page' => -1, ...
0
votes
0answers
19 views

meta query always fails even if data is correct

I've following query - $query = array( 'post_type' => 'accessory', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'accessory-bike', ...