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

Events with multiple event dates + permalink for each date

Hope you're well. I was wondering how to achieve something like this in wp: Bascally it's a list of events ordered by the event date. I know how to do that. But the tricky part is that an event may ...
1
vote
3answers
27 views

Using meta_query with multiple keys and compare values

I suspect I may be asking for the moon on a stick with this, but: I have a filter for my shows custom post type. The filter uses standard taxonomies attached to shows, but also allows the user to ...
0
votes
1answer
39 views

Comparisson between date() and a date from wp_postmeta

I am using the calendar plugin: "The Events Calendar", and is trying to get the events that are done. I can't see what it is that I'm doing wrong, but I'm pretty sure that my meta_query is wrong, ...
0
votes
2answers
18 views

Meta query with a sub query group possible?

I have searched all through the forums and WP docs, but can't find an answer to whether or not WP Meta Query permits a sub meta query. My problem is this: I have a number of types of promos (custom ...
0
votes
0answers
18 views

pre_get_posts filter meta_query without conflicting existing meta_query

I have a meta_key on all posts that is designed to check the current user role and only return the post if the user has an acceptable user role. The problem I am running into is that my meta_query ...
0
votes
1answer
26 views

Get all posts with a certain meta key, except for one with specific title

I need to return all posts with post_test_safe == 1 and exclude one with title ="Special title" Some kind of combined meta query but haven't got anything to work. function getAllPostIdsTest(){ ...
1
vote
1answer
39 views

Meta Query relation “AND” then set array accordingly

I have a search form on my home page that sets up the url query_string accordingly for the code below. When I use or I get results. However when I used "AND" for the relation I dont get any results ...
3
votes
1answer
54 views

compare meta_query in get_posts arguments

I like to exclude certain posts with a custom field. So if my_custom_field_ignore isset AND 1 ignore this post. If it's not set include it. This is what I have $args = array( 'post_type' ...
0
votes
1answer
32 views

How do I add an item to the WP admin menu?

I want to add an item to my WordPress admin menu - "News" - it's to contain a list of articles written about my company. Each article will consist of the following metadata: Headline Date Link to ...
0
votes
1answer
32 views

Querying by meta key and value

I have a custom post type which has an array as a meta data. Here's how it looks inside wp_postmeta table. meta_key: _allowed_companies meta_value: a:2:{i:0;s:3:"275";i:1;s:4:"8386";} Obviously, ...
0
votes
0answers
33 views

How to show specific meta keys of all posts in admin panel?

I have some common meta keys on every post. Ex: hotel_person, hotel_number All the posts have these two meta keys. I want to show these meta key values and the post titles. All these values and ...
0
votes
1answer
16 views

Show category meta in loop on homepage

I'm working on a site that groups content into 'issues' using categories. The home page shows the latest issue by pulling the category with the highest ID (thus the most recent). What I want to do is ...
0
votes
1answer
27 views

Multiple meta query from array

I need to do multiple meta query from my array. I have something like this: $search_term[] = array( 'key' => '_cmb_listing_status', 'value' => 'Active', 'compare' => '=' ); foreach ( ...
0
votes
1answer
21 views

Advanced Post Display/Pagination/Ordering

I am working on a project that requires some advanced ordering of posts and advanced pagination. Basically, we have posts in a category, lets call this category 'mycategory'. We then have post ...
1
vote
1answer
18 views

Admin Custom Meta Box - Pull Last 5 Posts from Custom Post Type

This is what I'm trying to accomplish, I have a custom post type of "demos", from here I can add custom CSS/HTML/JS to display a demonstration (online preview) of what it is I have designed/coded. ...
0
votes
1answer
98 views

Order by meta value pro first then meta value free in my search function

My meta key is geo_listing_type and this key have 2 meta_value, pro and free. I want to order these by pro first then free <?php get_header(); ?> <!--Start Content Wrapper--> <div ...
0
votes
0answers
18 views

Ordering a custom meta query

I have a events custom post type. Each event has to meta fields: eventstart and eventend. These are both YYYY-MM-DD style dates. I am trying to get a list of my events that have a start date OR end ...
0
votes
0answers
18 views

Meta query with compare by more than 2 fields

i have 5 sets of meta boxes in some custom postype. So.. i know how to compare two meta box values... Example: 'meta_query' => array( 'relation' => 'AND', array( 'key' ...
0
votes
1answer
43 views

WP_User_Query with combined meta query - not working?

I'm trying to use WP_User_Query class to list all users basing on their specific meta fields. When I use simple single-meta query, it works fine: $q = new WP_User_Query( array( 'role' => ...
0
votes
1answer
49 views

Query Posts, order by meta value

I've read a lot, tried a lot more, but can't get what I want: I have custom post types, which I want to order in DESC, orderby its meta value: The complete query with its arguments: ...
0
votes
0answers
58 views

How can get Custom Posts Sort by Hour

I need to show posts from 00:00:00 AM to 00:00:00 PM, and orderby day too. How can i do that? Look the following code: $programasQuery = new WP_Query(array( "post_type" ...
0
votes
2answers
42 views

Show single posts date, in a page of posts

In a page of posts, how do I show their date, instead of the page date? I have no php knowledge. Let's say I want to show the single posts date here, instead to the single posts title. <?php ...
1
vote
0answers
39 views

WordPress Filtering Custom Post Type by Metadata and Search Heirachy

I have a custom Post Type called cptMovie which has two Custom Field (Metadata) "Language" and "Box office" assigned to it. I also have a Custom Taxonomy called movieTax with 4 tax Terms "Action", ...
0
votes
0answers
24 views

WP_Meta_Query object with conditionals

I have a custom post type (Books) that is connected with a second custom post type (People). The Books CPT has an additional author meta box that if checked, it should appear on the additional People ...
3
votes
1answer
85 views

Order by meta_value_num DESC and meta_value ASC on WP 4.0

I have created a custom post type that I want to order by custom-field-1, which is boolean so its value is either 1 or 0, in DESC order (1 to 0) custom-field-2, which contains text and is supposed ...
0
votes
0answers
51 views

Custom Upcoming Events List for Events Manager Plugin

I'm using Events Manager plugin. I want to list upcoming events without widget. (2 event with big thumbnail image, after then 4 event with small thumbnail image.) Tried this code: <?phpfunction ...
0
votes
0answers
30 views

Orderby Meta Value and Query from Meta Query

The following query is returning blank with no errors and I'm not sure why. Query Arguments: $args = array( 'post_type' => 'games' , 'posts_per_page'=> -1, 'meta_query' ...
0
votes
0answers
29 views

How to compare date in post meta value

I have some custom meta fields. Some are date fields but WordPress saves everything as a string, so how can I compare the dates? $meta_query_args = array( 'relation' => '', // Optional, ...
5
votes
1answer
164 views

How to Compare Two Meta Fields

Consider two meta fields balance and monthly_price. How you would get all posts that has balance < monthly_price Thinking of creating meta query but our both fields are arbitrary or do not have ...
0
votes
1answer
27 views

Comparing 2 Decimal Numbers from custom fields and displaying posts

This is really confusing me. Hopefully you can help me. What i want to do, is search for a number and display anything that is either minus 1 or plus one of the search result. The numbers that it will ...
0
votes
1answer
24 views

Does meta_query working with value paramater higher then 999?

I am trying to get posts by price using query_post() function. Price must be in range between two values. This I made using meta_query. But when I cant get posts when right value higher then 999 in ...
0
votes
1answer
18 views

Wordpress giving a 404 page when passing a year argument different than the current year

On this page you will see I'm listing events that fall in certain months: http://conciergemaps.ch/events/ This is on Wordpress, When you select a certain month and year it appends the URL with two ...
0
votes
0answers
15 views

Sorting events by meta date value after current date

I have custom post type "Events" and also have custom meta box date, in default mode its working and sorting events with published date, but i want changing events sort by custom date, i've added that ...
0
votes
1answer
24 views

Return a single custom post from multiple meta queries

I'm currently working on a widget which returns a single random featured property on a website but I'm having some trouble with my WP_Query arguments. In the backend I have 2 checkbox meta fields ...
0
votes
2answers
63 views

What Is meta_id In wp_postmeta?

I am trying to add some data in WordPress Custom Field and via adding more direct records/data in wp_postmeta table via SQL query. There are four column as mentioned below... 'meta_id' - A unique id ...
0
votes
1answer
90 views

Selecting posts older than the current Unix epoch timestamp

I am trying to perform the following query, which originates by the fact the post's 'date' and 'time' are entered as separate custom fields. $args = array( 'post_type' => ...
2
votes
1answer
55 views

Is “orderby” in WP Meta Query conflicting with Meta Query?

I'm trying to write a meta query that looks for either events starting within the next year (event_start_date between now and 52 weeks), or events that are still going on (event_end_date between now ...
0
votes
1answer
30 views

Array sorting by custom field date

I want to order the array by a date field called date_start but how do I include a meta key for this if I already have one? $currentshowid = get_the_ID(); $today = date('Y-m-d'); $args = array( ...
0
votes
0answers
19 views

Is it possible to apply a meta_query to one specific post type in a query with multilple post types?

I have two post types, news and events : A news has no custom fields. An event has two custom fields : start-date and end-date. I want to display news and events on the same page, ideally with ...
0
votes
0answers
41 views

running queries of multiple post types

I am trying to figure out the query I need to build for my project. I've got a little idea but i am getting confused by all the different query methods and I'm not sure which one to use. I have two ...
2
votes
1answer
104 views

Meta query with string starting like pattern

I have a custom WP_Query with the following meta_query: $meta_query = array(); $meta_query['relation'] = 'AND'; if(!empty($postcode)) { $meta_query[] = array( 'key' => 'postcode', ...
0
votes
1answer
17 views

Unable to get the upcoming events for custom post

I have custom post ='events' and there is custom field 'event-start-date' for each events. I want to show the upcoming events for which I am using the following code. $date_today = time(); ...
3
votes
3answers
220 views

Meta query terribly slow

I have a custom meta query which is terribly slow or doesn’t even load till the end. With up to three arrays in 'meta_query' the query works fine, with four and up it doesn’t work anymore. When ...
0
votes
0answers
55 views

Filter RSS feed for custom post type to events for next 7 days only

I'm trying to create a custom RSS feed that shows posts from the custom post type 'events' for the next 7 days ahead only. The feed is already sorted by event start date order rather than published ...
0
votes
1answer
40 views

Meta query for comparing two dates

I want to list all users who registered in between the $start_date and $end_date.I have written a metaquery,but it returns empty.Please help. $start_date = 2014-08-16 09:28:17 $end_date ...
0
votes
1answer
56 views

The sorting of posts by a meta_query with two keys fails while separated as single queries it works

I have a list of courses I try to sort. For sorting purpose I want to use two advanced custom fields. First a select field class_day containing the days: 1 : Mon 2 : Tue 3 : Wed 4 : Thu 5 : Fri 6 : ...
1
vote
1answer
40 views

WP_user_query throws a 404 error

I'm trying to get Wordpress (3.9.2) to search meta_key's in usermeta. I have tried every example provided on every site I've searched but I keep getting redirected to the 404 error page. I've tried ...
0
votes
0answers
36 views

Exclude posts from certain meta_key

I have query to retrieve all posts, but how can I check the condition for post meta_key ="develop" and meta_value='anything' SELECT DISTINCT date(p.post_date) as post_date FROM $wpdb->posts p ...
0
votes
1answer
59 views

get posts where a custom field contains a text

I have a custom field where the value contains a comma separated list of items (like: test1,test2,test3), now I want to retrieve posts where the field contains one of the values, I have: $query = ...
0
votes
2answers
57 views

How to orderby meta_value_num with dollar ($) sign

The custom fields all have prices including $ signs, and a dot as separator. $theQuery = new WP_Query(array( 'orderby' => 'meta_value_num', 'meta_key' => 'price', 'order' => ASC )); All ...