Questions tagged [meta-query]
103 questions
0
votes
2 answers
Multiple WP_Query args combinations according to post type
I'd like to have separate meta_query arguments according to the post type.
For example, I'd like to query t-shirts that have a green collar or dress-shirts that have a green inner-lining, right now I only do a single post type check where I check…

martin schwartz
- 863
- 8
- 17
0
votes
2 answers
get orders by custom field (meta data)
I want to loop through my orders and get only the orders with a specific custom field and value.
function lwb_5483845() {
$args = array(
'limit' => 9999,
'return' => 'ids',
'meta_query' => array(
'key' =>…

LovinQuaQua
- 111
- 2
- 12
0
votes
1 answer
Wordpress wp_query: Order by meta_query key & then everything else by date (pinned / sticky)
I've been racking my brain over this for hours and now it's time to take it to Stack overflow.
I'm aware there's no easy way to do this and probably there is not a way to do this at all.
Using Wordpress, I'm trying to query posts but order them in a…

Sandy Garrido
- 168
- 5
- 21
0
votes
1 answer
How to get all posts if post don't have specific meta key?
I'm trying to add post filters based on specified post metadata. Filters works great but when I select "All types" filter doesn't reset and no posts are displayed.
HTML:
0
votes
1 answer
Meta Query Select ACF Not Returning Post For Current Date
I am trying to get a post type to return based on a ACF Select (multiple) of days of the week, Mon-Sund. I set up a meta query with a relation of both the ACF Select key (show_days) and the current date. The var_dump is showing that the two arrays…

EdgarAlexPoe
- 410
- 3
- 11
0
votes
1 answer
WC_get_products Meta Query being ignored
Im having problems with wc_get_products meta query. Im trying to exclude products that have clearance or express in the SKU and the SKUs are formatted like so; (not my choice something the company decided many moons ago!)
My Club - Express - Item
My…

blackhill24
- 422
- 14
- 30
0
votes
1 answer
Pushing Wordpress to its limits with advanced meta query filtering
Here is the situation, we have built quite a complex Wordpress site, whereby we have users who register and login to access pages on the site, with pages and assets in multiple post types all having taxonomies and custom meta fields assigned to them…

geoanderson
- 21
- 1
- 5
0
votes
1 answer
Meta query compare date
I need to query the date:- 2020-01-06 If this date ( 2020-01-06 ) exists in the _from field in the post meta table.
_form field is in timestamp format like 1578304800.
This is how I am trying to do.
$theBookingTime = strtotime( '2020-01-06' );…

Garry
- 69
- 8
0
votes
3 answers
Issue with function and post ID
I am using the following function/shortcode in order to output an average global rating using ACF :
function get_average_rating($post_id) {
$rating_sum = 0;
$reviews_of_post = get_posts( array(
'post_type' => 'avis',
…

Fabien
- 59
- 8
0
votes
0 answers
order by date format custom field in cpt
I have a cpt proposta_gite and a custom field data with j F date format
I would like to order my post by custom field data but this code won't work:
add_action( 'elementor/query/filter', function( $query ) {
$query->set( 'meta_value', date( 'j…

Marco M
- 1
0
votes
1 answer
WooCommerce using meta_query to get products where custom checkbox option is NOT checked
I have built a WooCommerce website for a client with a "Latest Products" page. Due to the competitive nature of the client's industry, the client wants to be able to select certain products to NOT appear amongst the Latest Products.
For this, I…

Graphic Detail
- 101
- 1
- 11
0
votes
0 answers
display events by month (cpt)
I've modified this post a few times, asking for help. And I finally got it figured out, so I thought I would share what worked for me.
The goal was to create a Meta Query in Wordpress on a Custom Date Field, in a custom post type. Not the WP Core…

MARWEL58
- 19
- 1
- 5
0
votes
1 answer
custom wp_query where meta_key is variable or not needed
To make a custom post type filterable and sortable, i created a custom query that works based on variables in url, accessed by $_GET.
One specific situation breaks it. This is an (un)specified metakey. In the case of sort, the metakey is needed when…

Webdever
- 485
- 5
- 17
0
votes
1 answer
Wordpress meta query not working with dynamic parameters
I'm trying to make a call using a custom end-point to one custom post type on my project.
I'm passing dynamic parameters to that function-
// $per_page = $_GET['per_page'];
// $page = $_GET['page'];
$per_page = 18;
$page…

Fábio Fernandes
- 23
- 6
0
votes
1 answer
Query a custom post type by another custom post type value linked to it by an ACF relationship field
I want to query a Custom post type Person, filter those people by their first name and the name of the City they are living in.
But I don't know the ID of the City but only it's name.
The City is in my case another custom post type, linked to the…

Florian Lucas
- 31
- 5