Heureka! Your suggestion got me on the right track, it was the date field formatting that was the issue. My date field that was setting the
$transaction_date was setup to return Y-m-d, but when setting a date field with update_field it must be in Ymd format. So a simple conversion before update_field did the trick!
Thanks @hube2 for leading me on the right track! 🙂
Hmm, that could’ve been it, but changing
$account->ID doesn’t make a difference for the issue.
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);
updated_balance is a number field, where
transaction_date is a date field and
transaction_account is a post object field selecting a
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
Hope this makes things at least somewhat more clear. Otherwise I’ll try to clarify further!
Did you find a solution to this @killianleroux ? I’m having the same issue and just can’t understand what’s wrong…
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!
© 2022 Advanced Custom Fields.