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
68 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
56 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
65 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
150 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
53 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 ...
1
vote
0answers
25 views

2 weeks ago from meta query meta value

This is my meta query within my posts query. 'meta_query' => array( array( 'key' => 'rw_membership_ends', 'value' => ??????? ...
0
votes
3answers
56 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
301 views

Using WP meta query to show custom post types by a start and finish date

I have a custom post type called 'events', I have a page which displays events by each month. Each event has a start_date and finish_date custom field (using advanced custom fields plugin) which ...
0
votes
1answer
307 views

Query by radio button ACF

I am making a page template that should display custom post-types that have meta value that matches the page title. Meta value is added trough Advanced Custom Field radio buttons, but the query is not ...
0
votes
1answer
82 views

Two queries – one with checkbox ticked, one without – comparing meta_query

I am trying to do the following: Two queries 1. Get all people that have director 'yes' ticked 2. Get all people that don't have director 'yes' ticked I have the first query all set up and works ...
1
vote
1answer
57 views

meta_query keys and sticky posts

The problem is that the code works but when i make a post sticky it doesn't appear at first. The function of the code: It only shows posts that have a thumbnail or a slideshow image. <?php $args ...
2
votes
2answers
134 views

CPT Meta Searching

I'm developing a WP plugin which uses custom post types and meta data. What I'm trying to achieve is having the meta data searchable. Here is some code that I found which searches the meta data fine, ...
2
votes
1answer
370 views

Order Posts by Taxonomy and Meta Value

It's possible to order posts by Meta Value. It's possible to order posts by more than one value. And thanks to the code below it's possible to order by taxonomy. But how can I alter the code below ...
1
vote
2answers
113 views

meta_query compare='!=' with multiple custom fields

a post has the following custom fields: 'my_custom_field' => 1 'my_custom_field' => 2 'my_custom_field' => 3 I now want to query all posts that do NOT contain the value 2 for ...
0
votes
1answer
392 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 ...
1
vote
3answers
139 views

Searching by meta values showing inappropriate result

I am working on a custom search by meta value and using this: print_r($_REQUEST); $args = array( 'post_type' => 'property_post', 'posts_per_page' => 10, 'order' => 'ASC', ...
-1
votes
1answer
319 views

Wp query by 2 meta field - check if they exists / have value

I am looking for the shortest most resrouce affective (not mysql query) to count the amount of posts that have 2 meta keys <-- if they exists i found this simple way at the codex but it checks for ...
1
vote
1answer
282 views

WP_Query using meta_query with relation OR and orderby meta_value doesn't work

I've been bashing against a bug for a few hours now, and can't seem to find my error. Could there be a bug with the relation type 'OR' in WordPress? $evenements = new WP_Query(array( 'post_type' ...
0
votes
3answers
803 views

Custom Query With Multiple Meta Key Value

I am new with WordPress development and I have found this query and I want pass multiple key and value in this query. My Query is: $querydetails = " SELECT wposts.* FROM $wpdb->posts ...
0
votes
1answer
25 views

Filter meta request

i've got a multisite where i query specific custom post types from one specific blog. It looks like this: function unify_results_filter( $input ) { global $wpdb; $blog_id = get_current_blog_id(); ...
0
votes
0answers
82 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
2answers
52 views

I would like to have add_post_meta to return the ID instead of true or false

I would like to know if there's a way to have the ID when we use the add_post_meta() function ? I need it so I could remove it using ajax calls. Is there a way to retrieve it or I'll have to make a ...
0
votes
2answers
52 views

Is it possible to load a different sidebar in single.php based on a meta_query filter?

I have a custom post type 'speakers' and I have a checkbox custom field (meta_query) to separate my Conference speakers from my Workshop speakers. I can filter my speakers with this meta_query and ...
0
votes
0answers
56 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
67 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
1answer
69 views

Passing conditional arrays to WP_Query() [closed]

I've looked around at a few places and could not find an answer. I was wondering what the best way to create a WP_query from possibly empty variables were. I have about 16 of these $_GET variables. ...
0
votes
0answers
19 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
40 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
72 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
30 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 ...
1
vote
0answers
152 views

WP_Query with meta_query dosen't return results

I am trying to get list of posts filtered by fields I added using the advance custom fields plugin. I have more fields that I want to use but it doesn't work as I want it to. Here is what the query ...
0
votes
1answer
451 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
101 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 ...
8
votes
1answer
255 views

Mixing regular and custom post types (with meta_query) on home page

Not sure how to achieve this. I'm trying to mix standard posts and custom posts on a site homepage but I only want to display the custom posts if a meta value is set. Displaying the posts works fine ...
5
votes
3answers
684 views

Using meta_query on pre_get_posts to exclude a particular meta_key value

I have a simple filter running on the main query on the front page, it should be excluding all posts with a particular meta value (by only including posts who do not have the meta_key set, or those ...
0
votes
2answers
51 views

WP Query - Is this correct?

Trying to debug, getting headache so I want to ensure that I have placed the query args in the correct place. I want to sort/order all my posts based on "myvalue". if ( have_posts() ) : /* Start ...
0
votes
1answer
1k 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
214 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
211 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
171 views

Query posts with numeric meta values within a given range

I'm building a rental agency's website with WordPress. I'm having difficulties finding a good way to store an apartment's availability in meta fields. Specifically, enabling visitors to find ...
0
votes
1answer
30 views

Order by meta value

I've a custom post type that has a custom filed called deck-number and client wants to sort the result by deck number. FYI, deck numbers are numeric values. So I used query like bellow. ...
1
vote
2answers
146 views

WordPress Core - Optimizing meta_query generated SQL?

I have a problem in a plugin of mine which uses post meta to store ownership of a post. Basically, my issue is that the WP_Meta_Query class generates one JOIN per meta_query query. I don't understand ...
0
votes
1answer
169 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 ...
0
votes
0answers
35 views

Advanced meta query help

I want to get posts according to the following logic: "If post status = publish or pending then get all records which have a meta value of less than todays date. If the post is in trash, get it ...
0
votes
1answer
281 views

Time sort with meta_key using UNIX timestamp failing due to date differences

I'm dealing with the following issue trying to sort a custom post type by a meta key created using the Advanced Custom Fields plugin Date and Time Picker add-on. The add-on creates a jQuery datepicker ...
0
votes
1answer
418 views

Check for the existence of custom field

I am using the Advanced Custom Fields plugin, and I want to do a query to show all posts where a "date" field is before today and where another custom field (a report) has a value. For now I have ...
0
votes
1answer
62 views

Sort Posts with custom meta key by default which is currently set as optional

I'm new to Wordpress so please bear with me. Please check this link The posts are currently sorted by date. But if you mouse over on Latest Articles you see there are other options for sorting like ...
0
votes
0answers
74 views

Meta_query weird behaviour

I have a custom field called date_from. Dates are stored in the yymmdd format (eg 20131104). When I use a meta_query to find posts in a specific date range the query works as expected, but when I use ...
0
votes
0answers
116 views

Why is WP_Query's meta_query not filtering results?

I am working on a wordpress site that utilizes WP_Query to find songs based on their category, tags, and other things in a tax_query, but it also groups in a meta_query which (should) find songs based ...
0
votes
1answer
101 views

Including 'cat' => $cat breaks meta_query

so, i have a custom loop that seems to be working everywhere but one place. $args = array( 'post_type' => 'post', 'meta_key' => 'wpcf-post-weight', 'orderby' => ...