Support

Account

Forum Replies Created

  • 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;
    }
  • 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);
  • 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

Viewing 5 posts - 1 through 5 (of 5 total)