Home › Forums › Front-end Issues › Taxonomy image = id, not url (or object) › Reply To: Taxonomy image = id, not url (or object)
ACF only saves the image ID. You cannot use an ACF field to save the URL in the DB.
If you really must have the url stored in the DB then
add_action('acf/save_post', 'add_image_url_for_acf_image_field', 20);
add_image_url_for_acf_image_field($post_id) {
// get the acf field, assuming it is set to return the url
if (substr($post_id, 0, 5) != 'term_') {
// not a term
return;
}
$term_id = intval(substr($post_id, 5));
$image = get_field('your-image-field-name', $post_id);
if ($image) {
// not the different meta_name value
update_term_meta($term_id , 'your-image-field-name-url', $value);
}
}
Then instead of using the acf function get_field() you use get_term_meta() https://developer.wordpress.org/reference/functions/get_term_meta/
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!
ποΈ Just one more day until the next session of ACF Chat Fridays! Make sure to register for the latest updates on whatβs coming in ACF 6.1!
— Advanced Custom Fields (@wp_acf) March 30, 2023
π Friday 31st March 3pm UTC
π Register here - https://t.co/3UtvQbDwNm pic.twitter.com/7xtEJakeQN
© 2023 Advanced Custom Fields.
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.