Tagged Questions

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

How to: get_user_meta - BuddyPress [closed]

What is the proper way to display User Meta in the BP Loop using this line from codex? <?php get_user_meta($user_id, $key, $single); ?> I added that line to the profile loop and switched ...
2
votes
2answers
2k views

Sort Posts by Multiple Meta Values

1) Custom Post Type named "Buying_Locations" 2) Each Post has three meta values of: State, City, Store Name QUESTION: How can you show a list of these posts sorted alphabetically by State, then ...
0
votes
3answers
2k views

LIKE %…% Meta Query

I have a serialized array as a meta value and I'm trying to run WP Query where it finds a specific value in the serialized array. Here's an example of the serialized array field: ...
0
votes
1answer
314 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' => ...
1
vote
1answer
631 views

Using OR in WP_Query negates the “NOT EXISTS” compare

I'm attempting to filter posts by a custom field that either are equal to 'new' or have not been set yet. I'm able to get either of those meta_queries to work on their own but when I use them in an ...
0
votes
1answer
354 views

WP_Query arguments: Loop through custom post type - get all entries except excluded meta_key?

Can't seem to find out what I'm doing wrong. $args = array( 'post_type' => 'wr_event', // my custom post type 'posts_per_page' => -1, // show all posts 'meta_query' => array( ...
1
vote
2answers
548 views

Multiple Values stored as array in Meta Query

I'm a little confused as to best practise for saving multi-select values in meta fields. Assuming <select multiple name="_casestudypost[]"> is my form field if I store ...
0
votes
1answer
436 views

datetime picker, timestamps and meta queries

I have a custom meta box with a datepicker. The datepicker outputs 2013-01-17 10:00 in my database for an event that is 01-17-2013 at 10pm PST. $eventlist = new WP_Query(array( 'post_type' => ...
2
votes
0answers
117 views

Is it possible to orderby multiple meta_keys when using meta_value_num?

Reading through the order & orderby documentation, it's not clear to me whether there is any support to order based on multiple meta_key values. Obviously, using meta_query I can return posts ...
0
votes
1answer
1k views

get_users meta_query

I can't get meta_queries working correctly on get_users(). For the life of me can't figure out what I'm doing wrong. $args = array( 'meta_query' => array( ...
2
votes
1answer
620 views

How to exlude posts that have certain meta_value?

I want to exclude some posts from the home page. So I want to use meta data, and filter all posts that are signed by meta_value=0. Like this: $args = array( 'posts_per_page'=>28, 'meta_query' ...
0
votes
1answer
872 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" => ...
4
votes
3answers
3k views

Using meta query ('meta_query') with a search query ('s')

Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field. My current query: $args = array( 'post_type' => 'post', 's' => $query, ...
2
votes
1answer
929 views

Order by meta_key with two meta_queries

This should be simple, but I just can't pinned down a good example of the correct syntax to do this. I want to order by the specified meta_key with two meta_queries. The problem is query_posts ...
0
votes
1answer
188 views

loop through custom post-type with two meta_keys

I have a custom-post-type named my_project. This post-type has two meta-boxes: is_featured is_featured_position So essentially in my backend of the post-type I can set a checkbox for is_featured ...
0
votes
1answer
491 views

Custom query (author is post_author or meta co_author) with Pagenavi pagination

I need to create a custom query for the author archive (where the author is post_author OR is a meta co_author), and it have to work with WP Pagenavi. The query is something like this (omitting $wpdb ...
4
votes
1answer
5k views

Nested meta_query with multiple relation keys

I am curious whether Wordpress is able to run nested meta_query, with each having different relation keys? As of Wordpress 3.0, tax_query is able to perform this function; I'm wondering whether this ...
0
votes
1answer
362 views

WP_Query meta compare must include ALL array values

I am allowing users to query posts using a form with checkboxes. I want the posts to be filtered by the checkboxes but instead of showing all posts that include the ANY of the meta values selected I ...
2
votes
3answers
196 views

meta_query results not the same with and without spaces

I have a meta_query that gets all the items with a price range between 2 variables. My problem is that 10 000 is not the same as 10000. How can I fix this? I have been googling but I'n not sure what ...
0
votes
2answers
978 views

pre_get_posts and set

I have some functions into my pre_get_posts filter. So, the problem is that when I set a meta_query, all the menus disappear from the page. function propersearchfilter($query) { $taxarray = ...
1
vote
1answer
443 views

How can I combine meta_query queries?

I'm trying to build combined meta_query queries but they don't work. Any ideas how I can implement queries like the example below? Thanks, Hinnerk Array ( [relation] => AND [0] => ...
0
votes
2answers
88 views

list or get meta_key where meta_value is 'something'

I'm trying to get with get_user_meta the meta_key where the meta_value is 'ive-read-this' But I do not get the value. What should I do?
1
vote
1answer
183 views

query order by date on custom type: wrong order

I know there are very similar questions ans answers out there already, but I simply cannot get my query to get into the right order. I have a custom post type ("bb_articles") with custom fields, ...
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 ...
10
votes
2answers
12k views

Meta_query compare operator explanation

I noticed that there are bunch of operator can be use for compare in meta_query. However, I am not quite sure what operator I should use, it is somehow confusing like = and LIKE operator. I would ...
0
votes
2answers
177 views

Query author's posts & posts that have author's id as meta value

I am trying to get posts with an author's ID as a meta value in the author.php template using additional request parameter. For example I want posts with john's ID as a meta value using a request ...
1
vote
1answer
140 views

How to stop wp_postmeta from being called on archive and search pages?

Currently, when I load a search or result page, it queries the wp_postmeta table which is leading to the page taking ages to load. I realise this is a result of this table being huge (70k rows), and ...
2
votes
2answers
270 views

What is an efficient way to query based on post_meta?

The problem I am having is when I allow users to filter posts it overpowers the database and things run extremely slow. I am unsure what the best way to query posts using meta values is. My site has a ...
0
votes
1answer
178 views

WP_Query Class custom field parameters

In the the class WP_Query, using the meta_query(array). The wordpress codex says that the 'value' is a string|array. The array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or ...
1
vote
1answer
116 views

Get content from pages with same meta_key from Database

I need help! I'm doing this template page and I want to get content from pages with the same meta_key. I want to display all pages thumbnails that has the value "red" in the meta_key. The problem is ...
5
votes
3answers
1k views

Complex meta query with 3 keys

I think the problem essentially relates to sql query structure and I am not an expert.... I need to search for posts (custom post type) by 2 parameters: pd_city pd_country Please note that ...
1
vote
1answer
133 views

Filter posts by meta query?

I made custom post type and used a meta query … For this link: ...
7
votes
2answers
455 views

meta_query sorting by 2 keys

I need to sort (custom) posts by 2 custom field values... custom field name 1: is_sponsored [ value can either be 1 or 0 ] custom field name 2: sfp_date [ timestamp aka current post date in seconds ...
0
votes
3answers
419 views

get Insert id for meta field

I'm in a situation where i also need to get the id of the inserted meta( meta_id for post meta and umeta_id for user meta) For eg i add a user meta ...
2
votes
1answer
256 views

meta_value_num sort glitch

i have a custom query, and I have a meta key that contains a sequence number: 1.1, 1.2, 2.1, 2.2... 11.1, etc the problem occurs when the numerical sequence gets in to double digits, ie. 5.11, 5.12, ...
2
votes
1answer
4k views

Can I query custom meta data through WP_Query

Ok, my question is a bit complex so I will try and give a general explanation and then go into details afterward. I am running WordPress 3.4.2 and I am using WCK Post Type Creator and WCK Custom ...
1
vote
0answers
329 views

How to filter a query by multiple meta keys and order by other meta keys

I'm trying to query posts using WP_Query and meta_query parameters: $args = array( 'post_type' => 'produkty', 'meta_query' => array( 'relation' => 'AND', array( ...
0
votes
1answer
2k views

meta_query with array as value

I am writing some PHP which allows users of my site to submit a form and query posts by their post_meta. Everything works fine except for one thing, I used Advanced Custom Fields to create the ...
0
votes
1answer
427 views

Meta query: get posts with value in a multidimensional array

I have a custom post type, Album, which has a custom field called 'tracklist'. Tracklist is a multidimensional array which contains a track title and track link, like so: $tracklist = array( [0] ...
-2
votes
1answer
140 views

Get all user with both meta_value

I was wondering if there were any efficient way of fetching all user comparing two different meta_key. I am currently fetching all user compared to the first meta, then loop trough the user_id to ...
1
vote
1answer
324 views

Filter posts with meta_query NOT IN where value has multiple values

I would like to use a meta_key to store multiple values in that key. Thereafter, I would like to filter away posts that do not contain a specific value in the key. In other words, just show posts ...
1
vote
1answer
915 views

search query within custom taxonomy term, post title and meta field

I want to create a search that does: Search within my custom taxonomy - custom-tags search the post title search select meta field ?? dont know search with custom post type - easy part I looked ...
0
votes
1answer
170 views

Querying meta values within an array

Okay so I'm using the relationship field from Advanced Custom Fields against a custom post type. The relationship lists countries, when these are saved they are within a serialised array: [country] ...
1
vote
1answer
452 views

Use meta_query to get title of associated post

I have two post types that I've associated in one direction by assigning Post A as a custom meta field of Post B. I need to search based on the titles of Post A and return the associated Post B ...
0
votes
1answer
63 views

Meta query stopped working

The following query stopped working all of a sudden and I can't figure out why. <?php $today = date("Y/m/j"); query_posts(array( 'post_type' => array('events'), 'meta_key' => ...
0
votes
1answer
1k views

$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?

I have a custom post type 'event', a custom meta field 'event_date' and a custom taxonomy 'locations'. I want to query $wpdb to retrieve posts in this way posts must be of the 'event' post type ...
3
votes
2answers
1k views

Query between two meta keys

I feel like I'm extremely close on this one but the query keeps on showing up empty. Basically, I'm trying to query the custom values between two dates. Records should be returned if the start date is ...
1
vote
0answers
345 views

Meta query with multiple custom fields for archives page ordering problem

I'm modifying the query for archives pages so that the posts showing up on year, month or day pages are queried by there custom field (start-date and end-date) and are sorted by custom star-date ...
0
votes
2answers
810 views

How to query posts based on lat-lng coordinate as post meta?

I'm planning a custom WordPress theme where the Custom Post Type (CPT) will have latitude and longitude coordinate as it's meta value. The latitude and longitude will be displayed as a Marker in a ...
0
votes
1answer
118 views

meta_query returning excluded result

I have a series of day slots per location, in a multicheckbox custom field. I have a search page where the user can select location, weekday desired, and activity type. Right now I just have 2 ...