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

1
vote
1answer
30 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
10 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(); ...
2
votes
3answers
46 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 ...
-1
votes
0answers
32 views

Is it possible to use meta_query with both AND and OR relations? [duplicate]

$args['meta_query'] = array ( 'relation'=>'AND', array( 'key' => 'canonical', 'compare' => 'NOT EXISTS' ), array ( ...
0
votes
0answers
14 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
16 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
32 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
22 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
29 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
15 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
41 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
0answers
31 views

Multiple meta data one label

I am wanting one label but multiple data to be under the label. I also want to reference each input option individually so that I can query for specific meta data. Currently I have, function ...
1
vote
0answers
100 views

Get specific repeater row (via advanced custom fields) based on Meta Query with Wildcards

I've used Example 5 of: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/ to query a post by a wildcard. However, my problem is I only want to ...
0
votes
1answer
28 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
0answers
16 views

Posts Duplicating due to Pagination and Custom Query

I have a custom meta field named “price” and I would like my main query to order the posts from highest to lowest price. Currently I have it setup like this: <?php $paged = ...
0
votes
1answer
141 views

WP_query - Filter by tax_query and meta_query using multiple select

I have a Publications Post Type, a Writers Taxonomy and a Publications Custom 'Meta Box' Value; parent_id. In my archive-publictions-post.php template I am trying to filter the WP_Query Class, with ...
0
votes
1answer
23 views

Multiple Queries with meta_query

I am trying to list posts in category 'Featured1314' split into two lists, upcoming events are >= todays date, past events are < todays date. I have added custom fields to the posts with the name ...
0
votes
3answers
122 views

Sort users by meta_value_num

I'm having problems using WP_User_Query to sort users by a meta value number, I would of thought this would be simple by it just displays results as descending alphabetically. <?php $args = ...
3
votes
2answers
233 views

How do you get posts by meta_query using the JSON API plugin?

I would like to get post with an API method using a kind of meta query. I have 2 custom fields "place" and "dayoweek" and I want to retrieve via API call all the post that have some values for this 2 ...
0
votes
0answers
39 views

Use custom field “date” compared to today's date to display & order post list

I am at a loss here. I have a custom meta field blser_date where the client can use the date picker. The meta field is setup in a meta box array (this may be an issue b/c of the key?) Here is the full ...
0
votes
0answers
52 views

Get the menu name or location of current menu item

I am having a hard time trying to get the name of the active menu and, apparently, I cannot find any solutions to this issue. Basically, I have several menus that follow this pattern: Menu Name ...
0
votes
0answers
66 views

Set right order for query that returns posts based on two custom fields

My query arguments are inspired by a solution here. I needed to get posts with custom field expert_intown but I also needed to exclude posts that have the meta_key coming_soon. My arguments works ...
0
votes
0answers
45 views

Custom Post Type: Event - Display Upcoming Events for Next 30 Days

I need to display the upcoming events for next 30 Days and sort the same based on custom date field. Below is the code I am using right now but not got any success in hiding old Events and ...
0
votes
2answers
35 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 ...
1
vote
2answers
49 views

Query that joins the postmeta table twice

I believe what I'm trying to do is too complex for the standard meta_query parameter in get_posts, so I'm trying to use a custom SQL query to do the following: I have a game custom post that has ...
0
votes
0answers
431 views

Displaying Metabox value (custom post type taxonomy)

I have been stuck on this for days, reading articles and articles and nothing works. I am trying to display the value of my metabox on a template page. I successfully added the metabox, and I see ...
0
votes
1answer
78 views

How make a custom search on backend in Wordpress without plugin?

I have a post type called usr_jardin with a custom field called sim_nuip. I would like to get the search to work for the title of the post and also by custom field . I try this but does not work me. ...
0
votes
0answers
25 views

Tax Query With Meta Query

I'm tring to using tax_query and meta_query in taxonomy-term.php I want to sort list by date custom field. Taxonomy name is sektorler, Meta Key is bs_fuarlar_baslangic My Code is; <?php ...
0
votes
1answer
116 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
22 views

Which Meta Query Compare Method Should I use?

How do I do a 'like' comparison on a numeric value with meta_query? I have some code that does an autocomplete search for product sku's in WooCommmerce. It works fine for non numeric skus, but I ...
0
votes
0answers
25 views

wp_query for events & posts filtered by category

I need to perform a wp_query to return events and posts. The events need to be in a specific category (stub = 'novita') and the posts in cat 15. I feel like I've tried every conceivable permutation ...
1
vote
2answers
64 views

Single meta_query query using OR instead of AND in request's WHERE statement

I want the native WordPress search input to search metadata in addition to its standard title and content search, however setting a meta_query adds an AND clause to the request when what I need is an ...
0
votes
1answer
54 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
2answers
63 views

get_post_meta with WP_query

I know this is a convoluted loop (inherited from someone else), and this must be pretty simple: the_permalink and the_title display OK, but why doesn't my post meta eventdatestart echo?. <?php ...
0
votes
1answer
43 views

Get foreach for meta_query value

How can i get meta_box foreach value inside meta_query value, here is code: $my_id = get_post_meta(get_the_ID(), "artist_name", true); $artistNames = array(); foreach($my_id as $id) { ...
0
votes
1answer
116 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
25 views

Check whether attachment ID is associated with more than one post?

Is there a function to check whether an attachment ID (=get_post_thumbnail_id(..)) is associated with more than one post? With "associated" I mean that a posts's meta value for the meta_key ...
1
vote
0answers
52 views

Configuring a meta query with multiple post types that have the same relationship on a single page

I am creating a client portal were my clients can maintain their projects and leave feedback. I have two custom post types called "Clients" and "Projects" and they each pull information from one ...
2
votes
1answer
30 views

wordpress custom_meta ordering of timestamps

So I have a wp meta query that is handling the searching of events which have a start timestamp, and an end timestamp, I want to return all results within the two dates a user picks in the search. ...
0
votes
2answers
108 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
0answers
9 views

CPT search using meta_query and meta key as array [duplicate]

Hi i got custom post type and meta key 'tf_elements' which is an array and look like this: a:28:{s:22:"Mikrofon bezprzewodowy";s:3:"Tak";s:19:"Mikrofon przewodowy";s:3:"Tak";s:39:"Sprzęt do ...
0
votes
1answer
147 views

Very slow query with meta_query on large database

I have a blog with about 200k posts and each one have 20 custom fields. I've been using WordPress Transients_API to cache queries, in the few cases where it can be used, but it can't be used in some ...
0
votes
2answers
271 views

Comparing arrays with meta_query in pre_get_posts

I'm working on a form for filtering a list of posts using custom fields created with the Advanced Custom Fields plugin. Because of the form, I'm using the pre_get_posts action to change the query via ...
0
votes
1answer
90 views

Advanced Search by minimum/maximum values

I'm building an advanced search form which allows me to search by different parameters. Currently, searching by taxonomies work fine. My issue occurs with trying to set a minimum price to search by. ...
0
votes
0answers
77 views

Ordering custom post type by multiple custom fields

I was wondering if you'd be able to help with an issue i'm having? I have implemented a fix that you came up with in this post: How to order custom post type by multiple custom fields? however when I ...
1
vote
1answer
65 views

How to Output which matched meta_keys were found from custom_type_posts?

In WordPress on the single-player.php page which displays a single profile (from numerous other profiles) with information from around 10 different meta fields. Without using tags or categories.. ...
0
votes
1answer
49 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 ...
1
vote
1answer
58 views

How to implement custom search with input fields?

I want to implement a search form like this: Loan Form In my theme I have a custom post type called Data with the Year and Money custom fields. I googled a lot but can't find a way to submit the ...
1
vote
1answer
142 views

Possible to create a permalink to sort with meta_key?

I feel like I've been all around the web and back again looking for an answer to this and it's really starting to grind my gears. Not sure if this is the correct way to do it, but I want to add a ...
1
vote
1answer
47 views

Permalink structure with $_SESSION variables

I have a project that has content being filtered throughout the site (many custom WP_QUERY calls). Originally there was no URL needs, just filtering by $_SESSION variable. Works perfectly, but NOW ...