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
0answers
8 views

Meta Query Filter by Tag

I currently have multiple pages, and in each page is a custom field which is named 'country'. In the 'country' field I have this value 'uk, usa, brazil'. What I'm wanting to do is display posts on ...
1
vote
1answer
17 views

Complex WP_User_Query call fails on production server

I'm having a very specific and hard to debug problem with a complex meta_query in a WP_User_Query call: I'm using this (simplified) code to built the query: // custom user role $arguments = array( ...
0
votes
0answers
9 views

Get custom meta box in custom post type using tag ID

I have a custom post type called Contacts, and in each of those post I have a custom meta box called number where a phone number is stored in each of the Contacts posts. I also have a custom taxonomy ...
0
votes
0answers
10 views

Pre_get_posts meta query value serialized array using multiple URL parameters

Using the 'pre_get_posts' action I'm looking to return all posts which match multiple URL parameters by defining the meta_query. For example: example.com/?size=large,small&options=green,blue,red ...
0
votes
1answer
17 views

Create custom query for search?

I have create search box using ajax.If i enter any value in search input box that this value search in post title or post meta data and get all data of this value in custom post type.also query check ...
0
votes
1answer
38 views

SOLVED - How can you query posts by advance custom field when the value is a serialized array?

Bottom for resolution Im going crazy I think. I cannot figure this out for the life of me. I have an advanced custom field that is a select box. The select box has multiple values and allows for ...
-1
votes
0answers
22 views

pre_get_posts and meta_query to display forthcoming events [closed]

I'm using pre_get_posts to target a specific custom post type archive page to display the forthcoming events. After trying several "combinations" it doesn't work - it displays only one post or none ...
0
votes
0answers
11 views

WP_Query filtered by simple checkboxes

I'm trying to build a WP_Query with specific filters, i.e., checkboxes and radio buttons. The checkboxes will filter the meta-data linked with my custom post type. The meta-data is the location. And ...
0
votes
1answer
41 views

WP_Query with MetaQuery issue

I'm facing a rather strange issue when attempting to pass in four different meta_query values to my WP_Query. Find below an example of my WP_Query search. Please bear in mind, if I remove and test ...
2
votes
2answers
39 views

Query sticky posts with thumbnails

I need to display max 5 latest sticky posts that have a thumbnail. And I need to have accurate counting of the displayed posts. I've tried to exclude sticky posts without a thumbnail with meta_query, ...
1
vote
0answers
67 views

meta_value_num not ordering all items

I am using meta_value_num to output a list of items in order by a custom field. The custom field value that is being passed is 1, 2 ,3 or 4. The order works for the first 7 items but after that they ...
0
votes
2answers
38 views

WP_Query Posts by Metadata from Option Tree

I am doing a WP_Query trying to filter out the posts by Metadata. $args = array( 'ignore_sticky_posts'=> 1, 'post_type' => 'post_projects', 'post_status' => 'publish', ...
3
votes
1answer
84 views

Use REGEXP in WP_Query meta_query key

I know I can use REGEXP in WP_Query like this: $query = new WP_Query(array( 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array( array( ...
2
votes
0answers
31 views

sort by date in Advanced Custom Field

I am trying to filter posts with certain values and sort by the date field using ACF module. I have succeeded in filter with package and type. But when i added date sort, its not working. Please help ...
1
vote
1answer
46 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
105 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
33 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
0answers
18 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 ...
0
votes
1answer
29 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 ...
1
vote
1answer
19 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
23 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 ...
0
votes
1answer
43 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 ...
0
votes
1answer
29 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 ...
1
vote
1answer
106 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
62 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' => ...
0
votes
2answers
27 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
53 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
30 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
32 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
47 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
35 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... ...
2
votes
0answers
67 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 ...
4
votes
2answers
123 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" ...
0
votes
0answers
40 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
32 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
31 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
55 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
117 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
2answers
126 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
0answers
36 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 = ...
0
votes
1answer
165 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
25 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 ...
1
vote
1answer
56 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 ...
1
vote
1answer
248 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
0answers
29 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 ) { ...
0
votes
1answer
190 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
21 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', ...
0
votes
1answer
130 views

How to delete only user meta value (not key) from usermeta table in wordpress?

I store multiple image in media library and save its id in wp_usermeta table. my metakey is 'images' and meta value in like '279,280,281'. Now I get the image from table like this: <?php $images = ...
0
votes
2answers
38 views

Wordpress altering my custom query, How to fix it?

I am querying for most popular posts by custom view count by using the custom query below, <?php $mostpopular_args=array( 'post_type' => 'post', 'orderby' ...
0
votes
1answer
38 views

Getting attachments by meta value

I'm stuck at a very simple point: I need to get all attachments by a custom meta key (and value). I'm developing a short code, so it has to work on every possible page. What I've tried so far: $args ...