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
0answers
34 views

How to compare date in post meta value

I have some custom meta fields. Some are date fields but WordPress saves everything as a string, so how can I compare the dates? $meta_query_args = array( 'relation' => '', // Optional, ...
0
votes
1answer
33 views

Comparing 2 Decimal Numbers from custom fields and displaying posts

This is really confusing me. Hopefully you can help me. What i want to do, is search for a number and display anything that is either minus 1 or plus one of the search result. The numbers that it will ...
0
votes
0answers
18 views

Sorting events by meta date value after current date

I have custom post type "Events" and also have custom meta box date, in default mode its working and sorting events with published date, but i want changing events sort by custom date, i've added that ...
0
votes
1answer
29 views

Return a single custom post from multiple meta queries

I'm currently working on a widget which returns a single random featured property on a website but I'm having some trouble with my WP_Query arguments. In the backend I have 2 checkbox meta fields ...
0
votes
1answer
107 views

Selecting posts older than the current Unix epoch timestamp

I am trying to perform the following query, which originates by the fact the post's 'date' and 'time' are entered as separate custom fields. $args = array( 'post_type' => ...
0
votes
1answer
35 views

Array sorting by custom field date

I want to order the array by a date field called date_start but how do I include a meta key for this if I already have one? $currentshowid = get_the_ID(); $today = date('Y-m-d'); $args = array( ...
0
votes
0answers
19 views

Is it possible to apply a meta_query to one specific post type in a query with multilple post types?

I have two post types, news and events : A news has no custom fields. An event has two custom fields : start-date and end-date. I want to display news and events on the same page, ideally with ...
0
votes
0answers
44 views

running queries of multiple post types

I am trying to figure out the query I need to build for my project. I've got a little idea but i am getting confused by all the different query methods and I'm not sure which one to use. I have two ...
0
votes
1answer
17 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(); ...
0
votes
0answers
61 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
53 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
85 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 : ...
0
votes
0answers
40 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
81 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
0answers
41 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 ...
0
votes
0answers
31 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
562 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
34 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
241 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 = ...
0
votes
0answers
58 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
85 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
75 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
69 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
0answers
1k 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
184 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
49 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
27 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
43 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 ...
0
votes
2answers
159 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
115 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
29 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 ...
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
247 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
579 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
0answers
107 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 ...
0
votes
3answers
79 views

Sort posts by post views and consider meta key

my code should show popular posts where the meta key "slider" isn't empty. Have anyone an idea why it doesn't work? The problem is that this code only shows posts with a slider image. But it ignores ...
0
votes
1answer
702 views

Programmatically set 'meta_query' for filter

I am trying to set 'meta_query' programaticaly for a filter which is supposed to filter a custom post type depending on the existence of a metakey. I have tried several ways, which I have left in the ...
0
votes
0answers
138 views

meta_query compare not working

I'm trying to run this WP_Query on tag.php, and it doesn't seem to work. $tag = get_query_var('tag'); $args = array ( 'tag' => $tag, ...
0
votes
0answers
69 views

Sort posts in dashboard using custom field; also include posts where field isn't set

I'm using a pre_get_posts filter found on this question thread here, to sort a custom post type in the dashboard: function xyz_event_sort_order( $wp_query ) { if ( is_admin() ) { ...
0
votes
0answers
85 views

Orderby custom date fields with meta_query broken on OR relation

I have an 'event' post type that has custom start and end date fields. In a block on the home page, I'm trying to show only upcoming or ongoing events. So, to achieve this, I'm doing a meta_query that ...
0
votes
0answers
21 views

meta_query works with single query but not multiple queries

This is very strange and I'm not sure why it is happening but this piece of code... $args = array( 'post_type' => 'property', 'sentance' => true, 'meta_query' => ...
0
votes
1answer
41 views

query post based on comparison

Each post in my site can be rated as 'good' , 'ok' , 'bad'. The values are stored in custom fields. I now need to show top 10 posts with maximum 'good' and it should not display posts with greater ...
0
votes
0answers
95 views

Multiple metadata checkbox sorting

I'm searching for a while but cannot figure how to do exactly... I want sorting my custom post type posts with multiple checkboxes metadata in front-end of an archive page. All store in a session. ...
0
votes
0answers
32 views

Wordpress Query Default Order if Meta Values Same?

If the main query args look like this: 'orderby' => 'meta_value_num', 'meta_key' => 'price', 'order' => 'DESC' What orderby does the query use if the meta_key value is the same for ...
0
votes
1answer
611 views

Matching Serialized Arrays with meta_query

I've asked a related question previously, but I think I've finally worked out the crux of my issue. I'm using Advanced Custom Fields and have a number of custom fields attached to my post type. I'm ...
0
votes
0answers
111 views

Query Posts Via WordPress URL

I wanted to learn more about querying post types and their custom fields in WordPress. I've got two questions... I've followed this tutorial on Advanced Custom Fields and am trying to understand what ...
0
votes
1answer
2k views

How to create/modfiy WP_Query to search in post title OR custom field?

I need to modify or create a WP_Query that will search for a search term in both the post title OR a custom field (called 'my_field'). I have been reading and trying for hours, but I am right back to ...
0
votes
1answer
294 views

Filtering custom post type on a combination of custom taxonomies and custom fields?

I have a custom post type "artist". It has an associated custom taxonomy "artist_type" with terms "voice", "actor", "corporate" An "artist" also has custom fields for gender, location, agerangefrom ...
0
votes
0answers
290 views

Unable to use meta_query between currency values when value is over 1 million

I am trying to add a meta_query that searches for values of the field price that are between two different values. As long as the values stay below $1 million it works great. However, as soon as one ...
0
votes
1answer
210 views

how to make URL link query string

I have pages with a custom meta field called "ctr_state", and it contains a state name, like "Arizona". I am trying to construct a hyperlink that will return an archive-like list of pages that match ...