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
266 views

How do I create my own nested meta_query using posts_where / posts_join?

Some of my posts (not all) have a price as a meta key/value. Today I use the pre_get_posts action so that my users can search for prices that are between a certain value. This is the code that I'm ...
2
votes
1answer
17 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
1answer
277 views

Query multiple meta values

I'm working on a 'checkbox filter' to query posts by checked values. See this link (EDIT: As you can see there are just 2 posts in this link, as soon as the user checks for 'MINI' it gets a good ...
0
votes
1answer
300 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
2answers
20 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
34 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
26 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 ...
9
votes
2answers
7k 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
0answers
35 views

Add custom fields meta_query to wordpress search function

I'm trying to extend the wordpress search function to include custom fields using the pre_get_posts filter: function test_custom_search_query( $query ) { $adv_custom_fields = array( 'field_1', ...
0
votes
1answer
18 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. ...
1
vote
1answer
346 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 ...
1
vote
3answers
118 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', ...
0
votes
0answers
37 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
41 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.. ...
1
vote
1answer
775 views

search query within custom taxonomy term, post title and meta field

I want to create a search that does: Search within my custom taxonomy - custom-tags search the post title search select meta field ?? dont know search with custom post type - easy part I looked ...
1
vote
1answer
27 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
102 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 ...
0
votes
1answer
25 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
26 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 ...
2
votes
1answer
444 views

WP_Query display next custom post from today's date

I have a calendar plugin that uses custom posts types to create events. There are several custom fields that allow me to create various and seemingly unlimited post queries. The one I'm currently ...
0
votes
0answers
222 views

Using a query to display custom post types based on ACF post_object

Basically the set up I currently have is two sets of custom post types which are: uc_university and uc_course I'm having lots of trouble trying to display a course based on a my Advanced Custom ...
1
vote
0answers
15 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
26 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 ...
1
vote
2answers
1k 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
1answer
71 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
69 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 ...
2
votes
1answer
76 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 ...
0
votes
1answer
21 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 ...
2
votes
2answers
88 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, ...
1
vote
1answer
26 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 ...
1
vote
2answers
52 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
47 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
votes
1answer
54 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
73 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
1answer
21 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
3answers
91 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 ...
3
votes
3answers
2k 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, ...
0
votes
0answers
31 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
24 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
32 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
22 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
32 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
36 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
8 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
32 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
15 views

How to get from a query an array of post names of a particular custom post type? [duplicate]

I need to get an array of post names (not titles) of a particular custom post type from a query. How to do this? My query: $query = new WP_Query( array( 'post_type' => 'fpps', 'post_status' => ...
1
vote
0answers
272 views

How to filter a query by multiple meta keys and order by other meta keys

I'm trying to query posts using WP_Query and meta_query parameters: $args = array( 'post_type' => 'produkty', 'meta_query' => array( 'relation' => 'AND', array( ...
0
votes
0answers
67 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
0answers
40 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. ...