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
103 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
39 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
43 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
36 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
53 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
23 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
70 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
363 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 event_date....
0
votes
2answers
89 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
39 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
124 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
45 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
271 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
56 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
44 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
72 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
29 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
126 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
137 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 I'...
1
vote
0answers
117 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
55 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
137 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
163 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 works....
0
votes
1answer
79 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
59 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
53 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
36 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
1k 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 (...
0
votes
0answers
43 views

Show posts in numeric price order using meta query combining 2 meta keys

I've built a custom estate agency website for a client but I'm stuck on this one last thing before it's good to launch. I'm using custom meta fields to allow for additional meta data such as Price, ...
0
votes
1answer
205 views

How to fetch WP_User_Query with multiple role arguments [duplicate]

I have two user role 1) vendor 2)freevendor Here i am trying to fetch user by there user role vendor and freevendor with the bellow code but query is fetching only freevendor. $vendor_total_args =...
0
votes
0answers
65 views

Custom Table for custom post type meta data

I'm looking to store the meta data for a post type in a uniquely named table. You see I have a site with a large amount of custom post types with a large a mount of custom fields. I want to clone ...
0
votes
2answers
39 views

How can I query on the year part of a complete date in a custom field?

My posts have a custom field named production_date and formatted YYYYMMDD. How can I form a meta_query to select only the YYYY part? $meta_query_args = array( array( 'key' => '...
0
votes
0answers
40 views

WP_Query using meta_query with LIKE doesn't return what it should

I am using this code to get stuff based on my custom field and custom content type. $searchTerm = 'bestafricanvideos'; $args = array( 'post_type' => 'sitemaps', 'posts_per_page' => -1, ...
0
votes
0answers
34 views

Query and compare multiple meta values

The problem: I have a custom post type of 'events' which has two metaboxes: cf_eventdate and cf_eventend. The first contains the event date, in the format: 2015-11-05. The second contains the end ...
0
votes
0answers
34 views

WP_User_Query from meta_key and orderby secondary meta_key

I have this code, which works as intended, but now I want to order these by another meta_key. I've tried using meta_query to get another key into the mix, but am still unsuccessful. I want to get all ...
1
vote
1answer
123 views

meta tags doesnt fetch data from permalinks

i have a page http://studyofjoy.com/categories/ i want to add custom meta tags to heading section like this: <meta property="og:title" content="<?php echo "title:" . $get_title_raw;...
1
vote
1answer
100 views

meta_query issue with multiple numerics

I'm having an issue with a search form. I basically have 7 input fields used to search different properties. All of them apart from the last two see to be working, as soon as I introduce the last two ...
2
votes
1answer
131 views

How loop through posts based on custom fields

I want to loop through posts and show only those posts for which the custom field i.e _shopis not empty I am always confused with meta query and even not sure that if this is possible using this ...
0
votes
1answer
29 views

Retrieve posts from meta key

I'm trying to query the list of posts using the meta_key but the result I got back was an empty array. To write the data, I used the following codes: $post_id = 2; $user_key = '...
0
votes
1answer
18 views

Using custom field as 'orderby' value causing post grouping by publish date

I am using WP_Query. Here is my query: $my_query = new WP_Query('category_name=test-category&posts_per_page=-1&meta_key=sort_name&orderby=meta_value_num&order=ASC'); Why is it ...
0
votes
2answers
64 views

meta_query: check if number exist

I'm using the following query to check if user id exist in a custom meta field: 'meta_query' => array( array( 'key' => 'participantes', 'value' => $user_id, ...
0
votes
0answers
37 views

Run query with meta key via AJAX

I'm completely new to AJAX, and I can't seem to find anything that's pointing me in the right direction. I have a table that contains one row for each post in a post type. Each row contains the posts ...
0
votes
0answers
114 views

Meta query in serialized array

I have a meta query made, but some of the meta fields I use are stored in serialized arrays(based on the documentation of the plugin I used to create them). What is the right way for me to make the ...
0
votes
1answer
67 views

Loop through two different sets of custom fields

I created a Custom Field ('custom_name') to allow content editors to specify a 'custom_name' (different from the title of the page) to any post created: custom_name - (Field type --> 'text') For a ...
-1
votes
1answer
58 views

add_filter > posts_where works partially

I started to work with this code: Used with meta_query in query_posts works slowly and i changed the code and started to work with add_filter function filter_where($where = ''){ global $wpdb; ...
0
votes
0answers
89 views

Used with meta_query in query_posts works slowly

Hey i have a problem this my code and if i used with all parameters i get from $_GET its start work so slowly..... (like 5 min). $checkbox = array( 'immediate'=>'כניסה מידית', 'air'=>'...
0
votes
1answer
52 views

Error in meta_query not get result

I have this WP_Query <?php $args = array( 'post_type' => 'banner', 'posts_per_page' => 25 , 'meta_query' => array( 'relation' => 'AND', array('...
1
vote
0answers
25 views

WP User Query Issues

I am trying to create a search of users to search for them using their first name, last name, billing phone, ID, or email. I have the following code written, but it does not pull in the correct data. ...
0
votes
1answer
126 views

Single meta key with multiple meta value in like comparison

How can I search posts with single meta key but possible multiple meta value in like comparison. Here is my array for query post. Array( [post_type] => post [posts_per_page] => 3 ...