Its work for me
add_filter('posts_clauses', 'sem_order_by_stock_status');
function sem_order_by_stock_status($posts_clauses) {
global $wpdb;
// only change query on WooCommerce loops when ACF fields are not requested in the WHERE statement
if (!is_acf_request($posts_clauses['where']) && is_woocommerce() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) {
$posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
$posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
$posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
}
return $posts_clauses;
}
function is_acf_request($text){
if (strpos($text, 'acf-field'))
return true;
return false;
}
thank you so much)
Hello
Help me please
I used wp_insert_post to create new post in cpt
what needs to be sent to the field “meta_input” add to Data Picker in ACF?
when I send in data (ex 2029) POST all right – https://prnt.sc/1x73dvk
but in new post acf field (Data Picker) only 1970 – https://prnt.sc/1x72yu8
for other fields all ok
My code like this
$advert_name = $_POST[‘advert_name’];
$advert_rent_date = $_POST[‘advert_rent_date’];
$advert_new = [
‘ID’ => ”,
‘post_type’ => ‘offers’,
‘meta_input’ => [
‘name’ => $advert_name,
‘date’ => $advert_rent_date
],
‘post_content’ => $advert_desc,
‘post_title’ => $advert_title,
‘post_status’ => ‘pending’
];
$post_id = wp_insert_post($advert_new);
Thank you so much
Cool thank you so much
and how send files to wp media library from custom form (no plugin)?
drag and drop plugins maybe
help please
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.