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
13 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 ...
0
votes
1answer
46 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" ...
0
votes
2answers
27 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
34 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
15 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
19 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
52 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
34 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
29 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
21 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
24 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
36 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
19 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
76 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
39 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
43 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
33 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
55 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
38 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
34 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
30 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
21 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
33 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
250 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
40 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
62 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
21 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
31 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
22 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
23 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
26 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
113 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:" . ...
1
vote
1answer
45 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
120 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
26 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
14 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
43 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
25 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
45 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
65 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
45 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
61 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'=>'כניסה מידית', ...
0
votes
1answer
47 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', ...
1
vote
0answers
22 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
89 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 ...
0
votes
0answers
20 views

How to sort by meta value, then by other meta value

I've been tasked with creating a 'fully automated' agenda for my client. The goal here is to create an agenda for a conference. The idea is that one shortcode will automatically populate the entire ...
1
vote
1answer
118 views

get_post_meta causes database queries

I want to know why my site's search results are slow. I've used the excellent Debug Bar plugin, and found out that each search result causes 5 DB queries, of which 3 are SELECT meta_key (see below for ...
0
votes
1answer
96 views

Use not custom fields in get_posts() meta_query?

Is it possible to use not custom fields in get_posts()'s 'meta_query' to use a or-relation statement with a custom field and a category id? Like this: $args = array( 'posts_per_page' => 6 ...
1
vote
1answer
24 views

Query metas (and not : query posts by metas)

If I understood well, the WP_Meta_Query from Wordpress allows you to query posts by metas. But what I would like to do is to fetch metas; not posts. And I would like to fetch those metas without any ...
1
vote
2answers
89 views

How to check a single number value against an array of meta_key values?

There seems to be a ton of information on checking a meta_key against an array of meta_values, but I want to do the opposite. I have a site with projects, and press reviews. When the client adds a ...