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
61 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 ...
0
votes
2answers
375 views

WordPress Screwing Up 'orderby' => 'meta_value_num' in 'pre_get_posts'

I have a bunch of _ai_price_int meta values set up as just numbers. This is how the table looks: meta_id, post_id, meta_key, meta_value 1309, 1111, _ai_price_int, 6550 1310, 1115, ...
0
votes
1answer
91 views

meta_compare not comparing whole integer

I have submitted an integer data via a form to my custom search page. I can get values properly if the input is single char (e.g. 1 ) but if the input is multi char (e.g. 100) it still compares ...
0
votes
2answers
72 views

I would like to have add_post_meta to return the ID instead of true or false

I would like to know if there's a way to have the ID when we use the add_post_meta() function ? I need it so I could remove it using ajax calls. Is there a way to retrieve it or I'll have to make a ...
0
votes
2answers
68 views

Is it possible to load a different sidebar in single.php based on a meta_query filter?

I have a custom post type 'speakers' and I have a checkbox custom field (meta_query) to separate my Conference speakers from my Workshop speakers. I can filter my speakers with this meta_query and ...
0
votes
1answer
31 views

Order by meta value

I've a custom post type that has a custom filed called deck-number and client wants to sort the result by deck number. FYI, deck numbers are numeric values. So I used query like bellow. ...
0
votes
1answer
531 views

Check for the existence of custom field

I am using the Advanced Custom Fields plugin, and I want to do a query to show all posts where a "date" field is before today and where another custom field (a report) has a value. For now I have ...
0
votes
2answers
134 views

comment meta_query for keys that aren't yet set

I need query help! I am trying to set up a meta_query (for get_comments) for keys that aren't yet set. I have some code that allows moderators to add a custom meta key to individual comments. Click ...
0
votes
1answer
2k views

exclude custom post type by meta key in wp_query

I'm trying to display a custom post type (properties) and exclude posts that have a certain meta value (sold). Is there a way that I can do this? I have this for my code so far: ...
0
votes
1answer
129 views

Ordering a mysql style datetime stamp with meta_query

I have a custom post type field that I am storing data in called football_game_datetime. Example format and values for this field are examples like: "2013-10-31 14:00:00", "2013-09-16 20:00:00", ...
0
votes
2answers
522 views

Event with multiple dates, display events chronologically

I've been breaking my head over this for days now and can't seem to figure it out (with the limited knowledge I have). I want to achieve the following: I have a custom post type 'Events'. Each event ...
0
votes
1answer
151 views

Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months

I have a post type that holds a custom meta field with a date in it. The date is stored in the format: yyyymmdd. On the archive page for this post type I want to create 12 separate containers, one ...
0
votes
1answer
480 views

Query posts by Author and/or by Tag

I'm pretty sure I need to do some sort of custom query, but not sure about the best way to go with it. I have an author page. It needs to display that author's posts. That's fine, I can do that. I ...
0
votes
1answer
939 views

Display products from specific category in shop page

I know many people asked for this question but I didn't find a proper way to do it. How to add a simple meta_query (product_cat) before the execution of the shop page's query. Maybe by using a filter ...
0
votes
1answer
318 views

Meta query - How to display a null meta key

At the base I have this query wich displays 9 randoms custom post type : $args= array( 'post_type' => 'adverts', 'orderby' => 'rand', 'posts_per_page' => 9, 'tax_query' => ...
0
votes
1answer
893 views

How to query posts with featured images

I basically want to use WP_Query to select 3 latest posts which have featured images and this is the only way I can think of. regards edit tried $query = new WP_Query( array( "post_type" => ...
0
votes
3answers
3k views

Wp_query order by multiple custom fields?

I am learning WP_query and recently ran into a problem. I need to do a query where i first filter trough one or more custom fields, which works great thanks to meta_query. However, i also need it to ...
0
votes
1answer
742 views

Meta query with timestamp using WP_query

I'm having a problem with an events system that I'm developing for a local roller derby leaugue. I have made a custom post type ('event') where a user can add a few different types of events ...
0
votes
1answer
700 views

Displaying posts with only upcoming dates according their custom field date value

I got posts that have starting date as a custom field value. I'm displaying few of those posts in my sidebar in ascending order so that the post with closest starting date is shown first. This is what ...
0
votes
2answers
118 views

Getting a custom post's custom field based on another custom post's custom field select

So I'm at my wit's end here. I've done this before plenty of times, but I think I have stared at this so much I am missing something. I basically have a custom post called locations. That custom ...
0
votes
2answers
391 views

Create an archive listing based on meta array

I've got an "event" custom post type, with a meta field is used for the event date. I've successfully created archive pages (year and month) based on the answer on a previous question (here). Now, I'm ...
0
votes
1answer
846 views

Search by meta_query

I am building a Wordpress site with an events feature. The events page was made with custom post types. I want to make it possible for people to search/ filter events by dates. For example, they can ...
0
votes
1answer
212 views

Querying multiple values from a single key

Bainternet assisted me earler with the relation AND parameter. What I need to do now is determine how to query multiple vales from a single key. If I try to specify two arrays with the same key the ...
0
votes
2answers
669 views

meta queries do 'either/or' checks

I have a meta_query like this , but 'relation' => 'OR' NOT WORKING, Does meta_query only do 'both/and' checks and don't do 'either/or' ? $args = array( 'post_type' => 'post', 'posts_per_page' ...
0
votes
1answer
20 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
36 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
80 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
77 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
2answers
48 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 ...
0
votes
1answer
28 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
19 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
1answer
61 views

Sorting by meta_key different to search criteria?

I've created an admin only page simply to view more information about subscribers to my website. The subscriptions are stored as Custom Post Types. All I want to do is make a condition that looks up ...
0
votes
2answers
60 views

Grouping posts by a custom meta value

I'm trying to output a list of dates that are held in a meta key called event_dates without duplicates. I've also tried a wp_query with a meta_compare but I'm not able to make that work either. Any ...
0
votes
1answer
485 views

How to get current page nearest parent id?

I am trying to get current page nearest parent id not top-level. For example I have added page like this: Now If I am in Junior Design Award 2013 page I want to get his parent id 765 not top-level ...
0
votes
1answer
94 views

tax query between operator like

I have a custom post called person and a taxonomy(like tags) called age. As far I have search tax query doesn't seem to support the between operator like meta query does. Is there a way to accomplish ...
0
votes
1answer
361 views

Ordering custom posts by meta field date

I've tried every combination of examples here on the boards and nothing seems to get me what I need. I have an events post type with multiple fields in a custom meta box, one of which is a date field ...
0
votes
1answer
343 views

Using WP meta query to show custom post types by a start and finish date

I have a custom post type called 'events', I have a page which displays events by each month. Each event has a start_date and finish_date custom field (using advanced custom fields plugin) which ...
0
votes
1answer
377 views

Query by radio button ACF

I am making a page template that should display custom post-types that have meta value that matches the page title. Meta value is added trough Advanced Custom Field radio buttons, but the query is not ...
0
votes
1answer
112 views

Two queries – one with checkbox ticked, one without – comparing meta_query

I am trying to do the following: Two queries 1. Get all people that have director 'yes' ticked 2. Get all people that don't have director 'yes' ticked I have the first query all set up and works ...
0
votes
3answers
1k views

Custom Query With Multiple Meta Key Value

I am new with WordPress development and I have found this query and I want pass multiple key and value in this query. My Query is: $querydetails = " SELECT wposts.* FROM $wpdb->posts ...
0
votes
1answer
25 views

Filter meta request

i've got a multisite where i query specific custom post types from one specific blog. It looks like this: function unify_results_filter( $input ) { global $wpdb; $blog_id = get_current_blog_id(); ...
0
votes
1answer
83 views

Passing conditional arrays to WP_Query() [closed]

I've looked around at a few places and could not find an answer. I was wondering what the best way to create a WP_query from possibly empty variables were. I have about 16 of these $_GET variables. ...
0
votes
1answer
31 views

WP Query / Meta Query [duplicate]

How can I use a meta query like this: >>>>>> KEY_X Conditional IS ABSOLUTELY REQUIRED <<<<<<<<<< array( 'key' => ...
0
votes
1answer
114 views

Meta Query for specific months

I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm ...
0
votes
1answer
306 views

Can't sort order of wp_query with 2 meta keys

I'm trying to display custom post types by excluding the sold ones but also by displaying them in alphabetical order from the county meta_key. I'm trying to use pre_get_posts but I'm not sure that ...
0
votes
1answer
483 views

Why doesn't my WP Meta Query return any results?

Is it not OK to accept a value from $_GET as the key in a WP Meta Query? I'm not sure why this code doesn't return any results... BOTH the queries for Price as well as bedrooms do not return any ...
0
votes
2answers
166 views

Query posts by searching for a string in a meta field

I'm trying to see if I can make this happen with the built-in meta_query function. I'm taking a $_GET variable and want to return posts that contain that string inside the meta_key urls. So far, the ...
0
votes
3answers
194 views

Filtering all posts AND sticky posts through meta_query

I have a filter that filters posts from the main loop depending on a user role (handled externally) The meta data is entered when adding a post/page. This is the filter - it works for filtering ...
0
votes
1answer
67 views

WordPress Mysql query and Duplicate

i've a problem with mysql query on my wordpress database. I've custom fields Country and City. At moment I have this query that show all the cities of "UK" Country $querystr = " SELECT wposts.* ...
0
votes
1answer
1k views

filter search result with custom post type meta key

The default search returns all post types, which is what I want. But for one specific custom post type I want to limit the result to a specific meta key value (a custom date that must be greater than ...