Questions tagged [meta-query]
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.
1,056 questions
0
votes
0
answers
47
views
How to adjust meta value to UTC time in WP Query
I'm displaying three lists of events on my site: past events, current events, and future events. The lists are sorted by a custom date time field. The code I have is currently working, but Wordpress ...
0
votes
1
answer
58
views
Query 'orderby' when there are multiple values for the same meta_key
I'm trying to create a custom sortable admin column for a custom post type that contains a "repeater" field. The plugin I'm using for this field saves the values as separate entries in the ...
0
votes
1
answer
70
views
How to order product for key exists?
I'm trying to order the woocommerce products by the existence of a specific meta key, in particular: I need to display first the products that have this meta key, and the all the products that doesn't ...
1
vote
1
answer
70
views
Select posts using @wordpress/data with query based on custom field always returns all records
I am trying to select records that have a custom field value that matches a search condition but the result is always all records
To register the custom field for my post type I am using the following ...
1
vote
0
answers
60
views
Display posts in correct month order using single date custom field
I have developed a WP Query that displays posts from a custom post type and taxonomy, and orders them by date using a custom field.
The posts have a single Advanced Custom Fields date picker field ...
1
vote
1
answer
239
views
Using Nested Blocks With Custom Query Block
I'm experimenting with a custom query block for the fun of it. I would like to leverage the components that come with core query inner blocks (title, excerpt, featured image, etc..). For this test, I'...
1
vote
1
answer
62
views
Sort posts based on an acf field called fecha value return longtext '20240517'
I have a field called acf date for certain posts and I need to sort these posts by this field, but the value comes in this format: '20240517' and I need to sort the posts in ascending order with this ...
0
votes
1
answer
575
views
Meta query with ACF relationship field
I have a CPT that contains Employee Bio information. Because we don't want to create accounts in wp_users for everyone, this data is implemented as a "regular" CPT living in wp_posts. Let's ...
0
votes
0
answers
47
views
Meta query sort order is lexigraphical instead of numeric
I'm working with lumber and have custom post types with ACF fields for height and width in decimals.
I'm trying to sort my posts first by height and then by width. I am using the following code:
// ...
0
votes
0
answers
57
views
meta_query post_date not returning results
I'm working on a query where I have a few conditions, one of them involving post_date. However, whenever I try to write my query, post_date doesn't return any matches. If I comment that part out, it ...
0
votes
0
answers
214
views
Admin products page column not sorting
I import products to my woocommerce site, and all the imported products have an category called "external".
Note: All the external products have a "_ei_product" meta key with an &...
0
votes
1
answer
67
views
WP Query: orderby with one meta key, but multiple values
I'm trying to order a wp_query using one custom field. It is a radio group with three values: G, S and B (These represent Gold, Silver and Basic). I've been following the documentation and have looked ...
0
votes
2
answers
227
views
How to use meta_query to retrieve posts from multiple custom post type
I am having two custom post type "meet_our_community" and "news"
I have added a checkbox field named 'add_to_meet_our_community' from the acf to 'news' post type.
Now I when tried ...
0
votes
1
answer
71
views
WP_Query not using relation key as expected and not producing any results
I have created a custom post type service-provider with custom taxonomies region and service-category - By itself, this search works as expected BUT I want to also search on an ACF field.
I have an ...
0
votes
1
answer
103
views
Is there a way to use MySQL JSON functions in meta queries?
There are JSON functions: https://dev.mysql.com/doc/refman/8.3/en/json-search-functions.html can be used to search in complex data with MySQL. In the case of meta keys and values it is an issue that ...