Support

Account

Home Forums ACF PRO ACF – getting fields in functions.php Reply To: ACF – getting fields in functions.php

  • Hi John

    Thank you so much for your time and effort.

    I’m getting a time-out. I think it is pulling to many posts.
    Thought about adding a query (the page is a custom post type), but now i’m getting an error message.

    Warning: htmlspecialchars() expects parameter 1 to be string, object given

    function my_acf_load_value($value, $post_id, $field) {
    $query = new WP_Query( array( 'post_type' => 'artikler', 'posts_per_page' => 1, ) );
    return $query;
    
      if ($query->have_rows('artikel', $post_id)) {
        while ($query->have_rows('artikel', $post_id)) {
          $post_object_id = get_sub_field('artikel_navn', false);
          $values = get_field('tekst', $post_object_id);
        }
        $value = implode(', ', $values);
      }
      return $value;
    }
    add_filter('acf/update_value/name=meta_beskrivelse', 'my_acf_load_value', 10, 3);