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

meta_query in $args ignored when called from theme

I have the below function in my plugin in the MyManager class. public static function test() { $numRowLimit = 6; $arrArgs = array( 'posts_per_page' => $numRowLimit, ...
0
votes
1answer
23 views

WP Meta Query - mixed AND / OR query doesn't work

I am absolutely boggled by this one. I am creating a search function for a property site - simple enough. Simple queries such as max_price, max_beds, rent_or_buy work ok. But I am trying to create a ...
0
votes
1answer
27 views

meta_query 'compare' => '!=' not working

I am using a custom post-type, in post there are a checkbox meta field for featured post. So there are two scenarios. First with featured posts Second with non featured When I called featured ...
0
votes
1answer
26 views

Unpublish Authors With not Fulfilled Fields

I want to unpublish profiles of users that doesn't have all extra fields that I've created filled. I use a custom meta_query in a user taxonomy in order to filter those authors, and that work, but it ...
0
votes
1answer
24 views

Exclude posts with certain meta data from search results

I'm trying to exclude al posts with certain meta data from the search results but so far it's not working. Here's the code I'm using: function ZoekGeenLegeItems( $query ) { if( is_admin() || ...
0
votes
1answer
20 views

query post by author gender

I'm using utimate member plugin on my website. for each member (author), I have a field to store the member gender. (Homme / Femme). the data is stored in my database, inside wp_usermeta. meta key ...
0
votes
1answer
26 views

Wp_query with 2 meta keys and array of meta values

Hi in my post_type=shop i have 2 meta keys and array of values Custom fields Name Values cu_status pending,processing,completed cu_date 12-Jan-2016 , 13-Jan-2016, ...... any ...
0
votes
1answer
23 views

Is it possible to retrieve all posts with a certain value for metadata?

Under 4.5, I have posts with meta_key as series and meta_value as 19, 20, etc I am trying to loop through them in a template, and I guess I'm a special kind of dense. Most recently I have tried ...
0
votes
0answers
28 views

Show list users based on two custom field values

I'm kinda stuc. I have added an extra field in the user profile for my authors, called ArtistCategory which can be Tattoo or Piercing. I'm using this key and value to filter for menu and gallery ...
0
votes
1answer
37 views

WP Meta Query for some meta (array) values

If I get my posts using meta_query by 'my_meta_key' only I get something like this Array( [0] => Array( [nested_key1] => something_I_want1 [nested_key2] => ...
0
votes
1answer
35 views

Query Posts that have or don't have a meta_value and order by the same ASC

I'm trying to perform a scheduled update to all posts, 10 posts at time. To achieve this, I run Cron job with a script that saves 2 post meta: $DATA: the data I want to be update $TIME: the UNIX ...
0
votes
0answers
39 views

WP_Query meta query not returning results as expected

I'm trying to run a get_posts query to determine if a users ID is either set as a meta key value or is included within the array of another meta key for an event on a given date. I am passing ...
0
votes
2answers
55 views

Conditional posts in WP_query for search

I have a custom post type that im trying to limit results in search. The CPT is a deal/coupon, with a start and end date for each of the deals. What I'm trying to do is only show these posts in ...
0
votes
1answer
52 views

Extending WP Query: Custom geolocation meta values work, but tax_query breaks

I've built a custom query for geolocation searches. I'm saving lat and lng within each custom post type as a meta value. My query extension returns results successfully when lat and lng are the only ...
3
votes
1answer
60 views

Nested query inside Logical operator OR not working in meta_query

I've been trying this for hours now and I have searched and haven't gotten a clue. I am trying to make a nested query with OR operator as a parent and AND operator inside it as child. The page keeps ...
0
votes
1answer
42 views

Nested array issue in meta_query

I am using following meta_query to search blog post according to following search criteria, search logic : if expire date set, check the expiry of the post, otherwise just include it if ...
3
votes
1answer
65 views

WooCommerce conditional meta query

For this question, I know how to solve it but I am hoping there is a better / faster way to solve it. I have a custom meta query in my product loop that doesn't display my product if the stock is 0, ...
0
votes
2answers
27 views

ORDER BY custom field value

Based on example here https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/ I'd like to modify the query $q = new WP_Query( array( 'meta_query' => array( ...
0
votes
1answer
36 views

ORDER BY custom field value out of where clause

Based on example here https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/ I'd like to modify the query $q = new WP_Query( array( 'meta_query' => ...
0
votes
1answer
32 views

Sorting posts by custom fields in meta_query

How to apply 'order_by' in WordPress query in the following example: I have a query to get all posts with custom field for event dates greater or equal current date. I can have up to 10 event dates ...
0
votes
1answer
30 views

Exclude post on loop by multiple meta key value

I need to exclude the loop two post with different values in your meta key (the same). I investigating got this code that works fine if I enter only one value in value =>. But if I want to enter ...
1
vote
1answer
64 views

pre_get_posts order by not working

I am using the pre_get_posts hook to alter a query before it runs. The posts in question are performances and so are date and time based. I want to alter the query to get all performances which are ...
0
votes
0answers
34 views

Meta Box Plugin - Adding field value inside echo

I am using Meta Box Plugin to add some custom options to my Page Edit. I added a field to add an image background to the header which is working great. This image background has a parallax background ...
0
votes
0answers
40 views

WP_Query with meta_query returns where zero expected

I'm using a WP_Query with a meta_query key to get results from a custom post type using the following code: $args = array( 'post_type' => 'werknemers', 'meta_query' => array( ...
1
vote
1answer
35 views

WP_Query with different postmeta filter for each categories

Let's say I have categories (cat1, cat2) and I have postmeta keys (date1, date2, status). How do I view all posts in all categories with these filters: For cat1, I want to apply WHERE date2 <= ...
1
vote
1answer
52 views

Two near-identical custom field types - one works, the other doesn't . What can cause this?

I'm using Advanced Custom Fields to add meta information to a custom post type and in ACF I've created two different 'Select'-dropdowns - one is called 'series' the other 'classification'. I run a ...
0
votes
0answers
22 views

meta_query against multiple custom fields

I have a set of ACF custom fields: event_type (values are "single" or "multiple") event_start_date event_end_date (this only shows up if event_type is set to "multiple") I need to be able to show ...
1
vote
1answer
61 views

Meta Query with date and time on the same Day before given time

I have a metaquery for a custom post type "events". Their start date is stored as a meta field in this format: 2016-02-05 19:00:00 These are my query args: $args = array( "posts_per_page" ...
1
vote
2answers
141 views

ACF Custom Field WP_Query, but need to get all posts, if field doesn't exist

I have a custom ACF field set on all posts, called event_date, I would like to grab all posts within a given category, but have posts that have event_date defined put first in DESC order of ...
0
votes
2answers
56 views

Advanced WP_Query with meta_query, orderby?

I wonder if anyone can help me with this little complex query with ACF. I have the following so far which should display: Pages, News Articles, About Articles and Involved Articles. Show: only ...
2
votes
1answer
25 views

failed to filter hook `get_terms_defaults`

I've failed to filter hook get_terms_defaults, I got this notices and it won't to load any term Notice: Undefined index: number in /var/www/html/wp-merwaa/wp-includes/taxonomy.php on line 1123 ...
1
vote
1answer
31 views

Meta Query returns wrong number of posts

I am using this meta query inside a category: $args = array( "posts_per_page" => 12, "post_type" => array( "event", "post" ), "post_status" => "publish", ...
2
votes
2answers
106 views

Sort Popular Posts by Views for the Last Week

I'm trying to sort the popular posts so it shows the most visited in the last week, but it hasn't worked. Anyone have an idea of why it isn't working? <?php $popularpost = new WP_Query( array ( ...
1
vote
1answer
40 views

WP Query with custom Shortcode

I have the following in my functions.php:- /** * Shortcode: Latest Properties */ function latest_properties_func( $atts ) { $args = array( 'posts_per_page'=> 5, 'post_type' ...
1
vote
0answers
195 views

get product title ID and price and product picture woocommerce by cat-id query select mysql

i have query that return categories in woo-commerce like this: SELECT wp_terms.term_id AS id, name FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id WHERE ...
1
vote
1answer
34 views

Get result from meta_query() between two numbers

I have value like :- if ( ! empty( $_GET['filter-area'] ) ) { $f = $_GET['filter-area']; preg_match_all('!\d+!', $f, $matches); foreach($matches as $key) { ...
1
vote
0answers
34 views

Meta Query posts not showing on ending date of custom field

I feel like my logic is off, but the short version is I have 2 custom fields spitting out unformated times for event-start-date and event-end-date. I don't want to show a post if the start-date is not ...
2
votes
1answer
57 views

A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value

I'm looking for a way to basically have an OR relationship between the date_query and the meta_query. Basically I want to combine the two WP_Query's. Get the posts from the last two weeks $args = ...
1
vote
0answers
26 views

meta_query not working as expected

I have 3 posts that each have two meta values. The first meta value is one that they all share (ac_parent_event). The second is one that is unique to that post (ac_thischild_date). For this function, ...
2
votes
2answers
112 views

List of posts by day of the week

I have Radio with programs and they are associated to day of the weak. Example: 1-Program Disco Nights plays at Monday and Friday 2-Pragram Crazy weekends play only at Sunday 3-etc 4-etc ...
1
vote
1answer
64 views

Order posts by meta value and Date

I'm trying to sort posts based on one post meta value and date. I'm using this plugin ( https://github.com/JonMasterson/WordPress-Post-Like-System ) to add like system to my posts. The code that ...
1
vote
0answers
81 views

get posts by meta_key from inside key of post meta

How can i get posts sorted out by meta_key from inner key array of post meta values, for more details please look at my code: // Example output of each post_meta, key is views array( 'all' ...
0
votes
1answer
45 views

get second ID from array

I need to get the second attachment ID from this function and put it into a separate custom field: add_action('pmxi_saved_post', 'replace_thumbnail', 10, 3); function replace_thumbnail($id) { ...
0
votes
0answers
103 views

Help optimizing slow WP_Query with meta_query

I'm trying to create a custom WP_Query. Right now, I have two meta fields, roi_min and roi_max. The ideia is to get posts that has a roi_min greater than the selected value, and a roi_max lower than ...
0
votes
2answers
124 views

How to use meta_query to check if a meta field has something set?

(Wordpress 4.3.1) I'm running a custom loop and only want to include posts that have file uploaded to a custom field: audio_file. I have tried many solutions around the web and so far nothing ...
0
votes
1answer
61 views

meta_query not working with the_content()

I have two custom post types: events and venue. I'm trying to query related events into the venue page. I have the related variable stored in a custom field for venues and the events related value in ...
1
vote
1answer
46 views

Query Multiple values for same key

I have tried to get 2 different posts having the values in $al. I can retrieve the posts one at a time but fail to get both together: $al = array('51.66963','51.60652'); $meta_query[] = array( ...
0
votes
1answer
38 views

delete_user_meta Delete one value out of array

The code I have is not working cause the value saved as array and I'm not sure how to fix this. // Remove favorite authors from current users DB function fav_author_remove_user(){ ...
1
vote
0answers
34 views

How can I create a WP_Query that returns posts where one meta_value <= another meta_value

I have a working, pretty complex SQL query hand-written in a function. For the sake of leveraging WP_Query optimizations, and simplifying my code for maintainability, I'd like to convert it all to ...
5
votes
1answer
843 views

Query WP REST API v2 by multiple meta keys

Using v2 of the REST API, I'm wanting to query some posts by multiple meta keys. With v1 I was able to format the url like &filter[meta_value][month]=12&[meta_value][year]=2015 and it worked ...