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.
2
votes
2answers
30 views
Sorting: custom query with orderby meta_value_num THEN by title
i try to run a custom post type query to match following criteria:
sort movies first by year in descending order,
after that ("inside" the year order) by title alphabetically.
desired output:
...
3
votes
2answers
40 views
Best practice - Meta Query vs. post_clauses for “left join” ordering
Moreso a psuedo-code question than actual code. I have some custom post meta attached to attachments, and created a list table column for this meta. The meta is either 1, or null (not set), but I am ...
0
votes
2answers
52 views
Get posts based on meta key/value
I have a custom post type "custom_author" which is selected when making a new post using a metabox dropdown with field key "chosen_author".
This is what my wp_postmeta looks like:
Where 13088 is ...
0
votes
1answer
23 views
WordPress Meta Query: Relation is not working correctly
I make a custom search box and let user do search. I have added required field to my editing panel by custom meta box. I have a post which have some meta data like London as place and 13021 as post ...
1
vote
2answers
49 views
Optional Meta Query
I have places stored as posts in WP's posts table.
I am doing some geo-locating using Geo Data Store (http://wordpress.org/plugins/geo-data-store/). This is working great for me, as I can currently ...
1
vote
1answer
41 views
Query by meta_key and order by meta_value_num return orderby date
I'm trying to use the orderby and custom WP_Query features of wordpress.
It works nicely to select item by their meta and to order by date.
Unfortunately, it seems that I could not get the post ...
0
votes
1answer
40 views
WP_Query with several meta_query-statements and order by meta_value
This is my query:
$the_query = new WP_Query(
array (
'post_type' => 'pass',
'posts_per_page' => '-1',
'post_status' => 'publish',
...
0
votes
0answers
11 views
paginate_links with meta_query showing incorrect number of pages [duplicate]
I seem to be having a strange problem with paginate_links, and I'm hoping someone can help. I have a custom post type for events, events have categories and a custom field for start date and end date.
...
1
vote
0answers
32 views
database query with more than a couple meta hangs and doesn't complete
I have a development website with about 70 checkboxes for custom fields. The idea is the user selects one or more checkboxes, it queries the database for all posts that have a meta_key for the ...
0
votes
1answer
25 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
48 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
34 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
43 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
74 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
51 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
54 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
86 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
72 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
204 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
43 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
54 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
30 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
47 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
38 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
183 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',
...
2
votes
1answer
135 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
27 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
55 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
61 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
129 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
213 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
216 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
170 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
110 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
101 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
170 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
171 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
173 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
50 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
248 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
113 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
196 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
392 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
146 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
111 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
197 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
437 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
201 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
119 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
311 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 = ...

