All Questions
2,682 questions
0
votes
1
answer
12
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
16
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 ...
0
votes
0
answers
22
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 ...
0
votes
0
answers
19
views
Inequality based on today's date and SCF date not working
I have the following custom query and I would like to exclude any posts whose SCF dates are in the past. I have checked that the custom date of the post is returned in the Ymd format and it is. I can ...
1
vote
0
answers
40
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 ...
0
votes
1
answer
28
views
Two related taxonomies. how to filter terms in second taxonomy depending on selected term in first taxonomy on Post edit page?
I have two custom taxonomies on the site - Countries and Cities.
The Country taxonomy contains over 200 terms, and the Cities taxonomy contains over 47,000 terms.
Naturally, editing content with ...
1
vote
1
answer
33
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'...
0
votes
0
answers
25
views
Problem making a WPQuery with ACF boolean
Well after hours and hours I find myself finally here, I am building a gutenberg block that is getting a custom post type data and making little cards with it, it works very well if I want to get:
All ...
0
votes
1
answer
29
views
Can't retrieve custom post type taxonomy term to custom post type editor
I have 2 main problems:
I can't seem to add editor_name custom field to default/native WordPress list of request URL query parameters.
This is the request WordPress is using:
http://localhost/wp-...
1
vote
1
answer
23
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
104
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
14
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
14
views
WP_User_Query get_count issue with meta_query relation
I'm using WP_User_Query to count the total number of users based on specific criteria. Generally, the following code works well:
$args = [/* your arguments here */];
$query = new WP_User_Query($args);
...
0
votes
0
answers
28
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
32
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
25
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
1
answer
41
views
My custom meta box with textarea field not saved
I created a custom meta box for my custom post type with address, phone, and map but only the map field type textarea not saved.
My code here:
// Add meta box
function vn_store_add_meta_box() {
...
0
votes
2
answers
97
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
32
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
16
views
Custom fields empty after refreshing page
I have added some custom fields to the Gutenberg editor, the purpose is getting these custom fields loaded in the custom-post-type.
Thats is all working, I was able to get the custom-fields in the ...
0
votes
1
answer
42
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 ...
2
votes
0
answers
28
views
get_meta_sql hook is not firing
WP_Query uses WP_Meta_Query. I thought this calls the WP_Meta_Query::get_sql() to define the meta query SQL which is where the get_meta_sql filter is applied.
I can't get the get_meta_sql filter to ...
0
votes
0
answers
20
views
custom post type with metabox custom fields
how to make meta custom fields in custom post type name jobs_board_cpt , I am using boilerplate ?
public function jobs_board_cpt() {
$labels = array(
'name' => ...
1
vote
1
answer
46
views
Metabox conditionals depending on post format and template in Gutenberg
In the classic editor, I used jQuery to display metaboxes depending on the current post-format or page template selected. If a user selected a different format or template, they would toggle depending ...
0
votes
1
answer
99
views
Passing a variable containing a comma separated list of values in a meta-query
My objective here is to collect a series of values from a custom repeater field into a comma separated list so they can be used in a meta query. The first part of this is operational, and I think ...
0
votes
1
answer
37
views
Order posts base on last favorite post by user
How can I order favorite posts based on the last post favorited by a user? Currently favorite posts appear based on post date.
$favorites = get_user_favorites();
$favorites_query = new WP_Query(array(
...
1
vote
0
answers
27
views
How can meta values from another site in a multisite be used in a custom query?
Currently, I am using the pre_get_posts action to create a custom query, ordering the posts based on a meta value like so:
add_action( 'pre_get_posts', 'my_custom_order' );
function my_custom_order( $...
0
votes
1
answer
37
views
Second featured image only shows in metabox preview after saving a post in the wordpress editor
I am trying to add a second featured image to the Wordpress post editor, and it seems all be working. When I select and image from the mediauploader the first time the image shows in the preview of ...
0
votes
2
answers
115
views
How to get products with the same custom attribute like ean code
I Try to get all products with the same ean code, but the query doesn't work and also doesn't give any errors. What am I missing?
Here is the code I use.
if (is_product()) {
global $product;
$...
0
votes
0
answers
71
views
How can I filter records in a custom post type list in the admin based on the ACF field in the post that contains the current user?
I have a custom post type called Projects that includes an ACF field named team_members which uses User as a field type and returns a User Array. I want to filter the post type listing so that the ...
0
votes
1
answer
21
views
WP Query filtering by custom category not showing all relevant posts
Here's a question I've been trying to solve all day:
I added a WP Query that would show posts from a category that the admin chooses with a custom field. The post is a custom post type called "...
0
votes
0
answers
23
views
SQL query based on two different custom field values
I have custom post type "store" that has two different custom fields: Coutry and City. When in the single country page I list all the stores in that country.
What I would like to do is to ...
0
votes
2
answers
40
views
Multiple meta value orderby clauses in a WP_Query
Is there a way to allow for multiple meta value orderby clauses in a WP Query? I have a query which retrieves records between meta keys start/end, and orders them ascending. I’m adding a new key for ...
0
votes
0
answers
30
views
coauthors_plus_edit_authors to display metabox based on author caps
Need to display the coauthorplus metabox with author capabilities.
On the documentation of the plugin they say its only with super admin and editor that the metabox is available.
Any idea to add a ...
0
votes
1
answer
505
views
getEntityRecords/useEntityRecords: How to use CPT metadata?
I use getEntityRecords as described in the official data API tutorial (https://learn.wordpress.org/lesson/retrieving-wordpress-data-records/).
I.e.:
const [searchTerm, setSearchTerm] = useState( ''...
1
vote
1
answer
53
views
How to compare Event period with Week period using get_posts(), meta_query, relation and compare
I have many posts, each post is an event with a period .
This period can be 3 hours, 3 days, 15 days, 3 month.
I defined the start time of event with start_timestampevents and the end with ...
0
votes
1
answer
54
views
Complicated `orderby` based on text in custom field
I'm doing a user query and looking to query users that are in a certain department (custom field) -- this works. Now I'm trying to manipulate the order....I'd like to use the meta_key for position and ...
0
votes
1
answer
89
views
doesn't save custom meta box data wordpress
My WP doesn't save my meta box data. I see the metabox and the field, but the data doesn't saving. Somebody could help me? Thank you. This is the code:
<?php
// Function to add a metabox
function ...
0
votes
1
answer
81
views
Only display top level taxonomy on the edit post page with option to expand sub-categories
We have a custom taxonomy that is hierarchical. It has so many sub-categories that to scroll through them in the edit post page is proving problematic for editors.
Is there a way to initially show ...
0
votes
1
answer
22
views
Query custom fields with three dates - start and end does not work
I have tried to make a reservation system for a book a table in restaurant.
But, I have a problem when I try to see/ make new reservations in an specific day - in showing me which table are free at ...
1
vote
1
answer
196
views
Using add_meta_box on a page with file upload and importing fields
This must be fairly simple :) I'm trying to import data into ACF repeater fields and am mostly following the answer to Add special meta box to custom post type
But what I have below isn't saving the ...
0
votes
1
answer
20
views
Saving custom input from settings sidebar of pages in Wordpress
I created a meta-box with an input field in the settings sidebar of pages. Now I try to save the value, but it does not work. Maybe the problem is, that I try to do this with pages and not with posts. ...
0
votes
2
answers
79
views
Meta query array - same order as specified order in value
I have a custom Wordpress query that is using an array of product IDs that exist in an ACF field(these IDs do not line up with the Wordpress post IDs). I would like for the order of the returned posts ...
0
votes
1
answer
192
views
How to change the text of Publish Button
I am trying to change the text of the publish button to save.
I could change the text.
BUT, When I click Status Edit button and OK button, it change "Publish".
How can I fix this?
This is ...
1
vote
0
answers
81
views
Post Query with Meta Query no longer working
I am working on a magazine website that has a large amount of posts, submissions, etc. There is about 60K+ posts/submissions on the site right now. I don't know when it happened specifically, but ...
0
votes
1
answer
302
views
How can I put a checkbox in the post editor
Up to now I'v been able to insert text custom fields and number custome fields in my post editor page, now I need to insert a checkbox, as a new meta field. I write here the code I have for a number ...
0
votes
1
answer
55
views
WordPress - Optimize the Meta Query for 3 meta keys at a time
Records in post_meta as follow:
post_id
key
value
1
price
10
1
price_to
5000
2
price_type
'POA'
3
price
12000
3
price_to
17000
4
price
1200
4
price_to
8000
5
price_type
'POA'
Code Snippet
&...
0
votes
0
answers
222
views
How to consume external API from WordPress post editor and display the response data in the custom field?
I am developing a custom post type called "Team," where I will add some profiles of team members. I am using ACF for the custom field to add personal details of the members (I can also ...
0
votes
1
answer
143
views
how making a selection from a taxonomy selector fixed definitively
I have created a taxonomy “Ospiti” (guests) and set a selector in order to write the number of guests. If I select the number “7” and then edit the post , I see in the posts admin colum the n “7” ...
0
votes
0
answers
305
views
WP Query returning all posts when Meta_query is null
I have a situation here where we have two input fields, one is searching by custom meta fields (ACF) the second is a free search.
the client is asking me for results to display in an OR fashion.
If ...