Support

Account

Home Forums ACF PRO Meta query doesn't work after update_field until manual update in admin Reply To: Meta query doesn't work after update_field until manual update in admin

  • Thanks for your response @hube2 ! I’ll try to fill in:

    The fields are set like this:

    $updated_balance = get_field('updated_balance', $post_id);
    $transaction_date = get_field('transaction_date', $post_id);
    $account = get_field('transaction_account', $post_id);

    Where updated_balance is a number field, where transaction_date is a date field and transaction_account is a post object field selecting a ik_account CPT.

    All these fields are set on a new ik_balance CPT post when a ik_transaction CPT post is saved.

    So, in the query, I’m first looping through all posts of the ik_account CPT, getting only the post ID which is what’s populating $account_id. Inside that loop, the above query fetches the last ik_balance CPT where the balance_account post object field equals $account_id.

    Hope this makes things at least somewhat more clear. Otherwise I’ll try to clarify further!