Support

Account

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/