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
to $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);
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!
Did you find a solution to this @killianleroux ? I’m having the same issue and just can’t understand what’s wrong…
Was there an answer to this? I’ve got the same issue. The problem is not getting the value in front end, the field doesn’t show up in backend on the front page of other languages.
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.