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
13 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
14 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. ...
0
votes
0answers
7 views

Showing all data when no metadatafilter is active

I'm trying to understand how metadatafilters work. I've come quite far I think, but Right now I have a final problem. If a metadatafilter is selected, my page shows results fine, but I really want ...
1
vote
0answers
18 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
17 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
16 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
28 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
13 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
34 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 ...
3
votes
2answers
87 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
22 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
22 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
20 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
25 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
50 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
61 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
19 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
67 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
19 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
29 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
82 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
22 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
97 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
17 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
64 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
35 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
24 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 ...
0
votes
2answers
69 views

WP_Query with multiple meta fields filter?

I have the following query but it is still returning results which include posts which have a meta value of 'deal'. Any Clues on what am i missing in this $args = array( 'post_type' => ...
0
votes
1answer
22 views

Calling Specific Pages with wp query Part II

I'm making one page website and I added a custom field on "Page" post type that asks "Use this page as a section:" Yes or No(with dropdown). I called all pages on template-onepage.php(custom template) ...
0
votes
0answers
12 views

Querying sanatized data with meta_query in Wordpress

I asked this question over at SO yesterday, but I see now that this is the right place for it to live. After Googeling this for a while, I've found that this should work cite, but I don't seem to get ...
4
votes
2answers
190 views

Execute a large WP_Query with many “AND” Meta_Queries?

I have a custom post type product. Visitors can search products with many filters. They can set the color, the size, the price, etc. The details of the product are stored with Advanced Custom Fields ...
0
votes
2answers
80 views

wp_query check if integer exists in custom field's array

I'm using a wp_query to find custom posts that have a specified numeric value inside of a custom field. That custom field's value is an array of numbers (IDs of selected posts using Advanced Custom ...
0
votes
0answers
49 views

Build a query in wordpress , showing Post with Meta

wanted to build query to fetch, meta with Sticky = true. I have used , WCK plugin, https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/ and created , "thumb" and "sticky" ...
1
vote
1answer
60 views

Get attachment by meta_key value

I need to get the attachment (will be only one per post) associated to a post with meta_key wpcf-legislacion-gratis (not matter the value the column has) by using a custom query using get_posts() ...
0
votes
0answers
23 views

Use more than one post meta inside the loop

I have custom meta like this: I want to select the post with both of these conditions are true for : 1- end_date = "some date" 2- st_date = "some date" Also I need it to select by title ...
0
votes
0answers
22 views

meta_query argument not working

I am trying to use WP_Query to search through posts BUT I want to also search by post_title as well, which is why I tried using meta_query in my arguments array. I want to actually do more than just ...
0
votes
1answer
24 views

Using orderby with 2 meta keys

I can use orderby with one meta key in the WP_Query using following: 'orderby' => 'meta_value_num', 'meta_key' => 'my_key_1', However is it possible to use orderby based on the calculation ...
0
votes
2answers
67 views

get_users with Serialized Custom Meta Value

I'm attempting to use get_users to select users with only a certain meta value. In this case the meta key is extraInfo but the the values are in a serialized array. Can I pull users out like this? ...
0
votes
0answers
188 views

ACF Relationship Field Search Filtering

I am trying to assign relate posts using the ACF relationship field. It has typeahead search to search by post titles. I would like to add meta_data search to the ACF relationship search. This ...
2
votes
1answer
162 views

WP Query Args - Title or Meta Value

How do I query by meta_value or title? If I set meta_values, $args['meta_query'] = array( 'relation' => 'OR', array( 'key' => 'model_name', 'value' => $thesearch, ...
0
votes
1answer
21 views

Is there any difference between below WP_Query code snippets?

Below code return the same results. Is it any difference between them and if it is then which one is better? code snippet 1: $args = array( 'post_type' => 'product', 'meta_key' => ...
0
votes
0answers
34 views

Get closest event where meta_key field is an array

I have a custom post type called "Event", which contains a repeatable date field _cmb2_date . I have a function which prints out posts: function post_style_6($args) { global $post; $the_query ...
0
votes
2answers
48 views

Get meta info related to current post

I'm trying to get the meta info by key rw_related_link for each post but my code is wrong since instead get the ones related to the current post I got the same in all post and that's wrong. This is ...
1
vote
2answers
51 views

Query posts if meta key starts with

I need to find posts with a meta key that starts with the current year + the current month (i.e. 201502), but the actual value could also contain any day within that month (i.e. 20150214). The ...
1
vote
1answer
91 views

How to order a post type with meta_value_num and if meta_value_num does not exist then order by date

I want to order a list of post on basis of ratings. I have used meta key "wp_ratings" for storing the rating value in wp_postmeta table. Now I want to sort all posts . If a post does not contains the ...
0
votes
1answer
55 views

add_query_arg to compare and display events from a certain date

I have archive-events.php file that sorts custom post type 'events' via WP_Query using custom field that is date formatted YYYYMMDD (20150215) like this: $args = array( 'post_type' => ...
0
votes
0answers
38 views

get_post_meta doesn't work with variable

The $event_count variable doesn't prints anything, what am i doing wrong? global $post; $event_count = get_post_meta($post->ID, 'eab_event-bp-group_event', true); $args = array( 'post_type' ...
1
vote
1answer
107 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 ...
0
votes
1answer
77 views

Sorting posts by ACF field

I am trying to sort posts by the 'prempost' ACF field, but it's not working (just shows default order). Can anyone see where I'm going wrong? ACF support suggested that I use http_build_query, which ...
0
votes
2answers
186 views

Filter query based on date in custom field

I have a custom post type jobs and custom field with key expiry-date which the user enters the date after which the post will no longer be displayed. Here's my code so far... $loop = new WP_Query( ...