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.
0
votes
1answer
18 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 ...
0
votes
0answers
22 views
Search with meta_query and tax_query
I'm working on a little database for series based on wordpress. I've implemented a custom post type called "anime", some taxonomies (Genre, a_types..) and a lof of customfields. (based on acf). Now ...
1
vote
1answer
34 views
Perform query with meta_value date
I am trying to perform a query on a custom-type post using the value of a custom field.
This field contains a string date: dd.mm.yyyy.
The post type name is 'event'
The custom field name is ...
0
votes
1answer
41 views
Filtering a WP_Query meta_query by numeric values isn't working
That was a very dense title.
I have a custom post type "event" which has a Date/Time picker field "event_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX ...
1
vote
1answer
41 views
Mysql query and order meta value
I made a mysql query to WordPress like this:
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND ...
1
vote
1answer
43 views
Change order of posts
I made a post recently that did not explained myself right!
Come again, but with better explanations.
I need the "Select Option" change the order of query_posts.
My current code is:
<select>
...
0
votes
1answer
55 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
45 views
How to query wp_postmeta table for any specific meta_value?
I am using following code in the theme files to get some output from the DB:
<?php $querystr = "SELECT DISTINCT meta_value FROM $wpdb->wp_postmeta WHERE 'meta_key' LIKE 'movie_name' ORDER BY ...
4
votes
1answer
181 views
Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
I've registered custom rewrite rules and query_vars to use for displaying a list of events based on ISO date format. For example when a user requests the URL, http://site.com/by-date/2013-04-04/, my ...
2
votes
1answer
41 views
XOR functionality for meta_query
I'm trying to resolve the problem with event displaying.
An event has its start and end dates, written in meta. For example, event starts on (dmY) 03.04.2013 and ends up on 08.04.2013. Using WP_query ...
0
votes
1answer
52 views
Checking if field is set before comparing with meta_query in query_posts?
I have a query set up to compare the start and end dates for some custom fields. The start date is required for the post; however, the end date is not. This causes some issues with the following:
...
1
vote
0answers
25 views
Meta Query And/Or
My question is very similar to Meta Query with AND & OR? . This question was answered in 2011 by @Otto.
With the exception that my logic is different.
I want to query, for example, posts with ...
0
votes
0answers
40 views
Pre Get Posts / Multiple Meta Keys / Orderby Single Key
Tried more than a few variances to enable my pre_get_posts callback function to display posts that possess one, or both, of 2 separate meta_keys, upon display to then orderby a single meta_key.
Here ...
0
votes
0answers
36 views
WP_Query - How to show last post from each meta value
I have a custom post type where I have testimonials which are all grouped by 6 industries (meta value).
On the post type archive page I would need to show the last testimonial from each of the 6 ...
1
vote
1answer
138 views
wordpress get meta value by meta key
How to get the meta value by meta key
I want to get the value by the meta key.
This is what I have tried so far:
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
...
0
votes
0answers
38 views
All in one event order by
Im using All in one event calendar. On my single event page I want to query some dates and sort them by start date. My query looks like this:
<?php $event = ...
2
votes
1answer
108 views
Using database meta_values to calculate new post order using pre_get_posts or a 'request' hook
UPDATE: I have worked out my implementation of the selected answer at the bottom of this post.
I'm implementing a sorting algorithm based on Reddit's hotness algorithm, in addition to a time-decay ...
0
votes
1answer
26 views
Filtering problem
I got the custom_post_type_data in which I store some variables when I make a new post. Variables likes Author, Price etc.
I implemented a filtering by author, so when you click on James (for ...
0
votes
1answer
49 views
meta_query fails to compare on values containing apostrophes
I have WP Query and I am simply comparing by the meta value by =
My value contains town names, and seems to work great for the majority of names.
However some names contain apostrophes... Madonna ...
1
vote
1answer
52 views
How to add a new meta key and assign timestamp to posts
I've been trying to look for a way to create a loop in my website and show posts being read/watched but have not found anything.
The only way I can accomplish this would be to create a new meta key ...
2
votes
1answer
119 views
order by meta_value serialized array
Hi I'm trying to pull posts using the wp query. Just one problem--I am trying to sort the posts alphabetically by a certain meta_value. Thing is that this meta_value is a serialized array. Is there an ...
0
votes
2answers
171 views
How to: get_user_meta - BuddyPress
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 ...
1
vote
2answers
133 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
2answers
117 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
95 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
0answers
52 views
Complicated Custom Post Type Query drill down, using meta query
I currently have defined a few custom post types.
a product category size
a product category
a product.
Inside my product, I hold and save meta data on a dropdown list of product categories. So ...
1
vote
1answer
81 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
153 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
150 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
160 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' => ...
1
vote
0answers
49 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
203 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(
...
0
votes
1answer
97 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
155 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" => ...
3
votes
4answers
311 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
139 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
106 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
175 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 ...
2
votes
1answer
367 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
189 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
118 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
276 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
183 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
57 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
92 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
2answers
770 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 ...
5
votes
1answer
2k 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
71 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
85 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
126 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 ...

