Home Forums Backend Issues (wp-admin) Invalid Array from Relationship Field Type Reply To: Invalid Array from Relationship Field Type

    // use get_queried_object because you might not be showing
    // something that returns an value for get_queried_object_id()
    $queried_object = get_queried_object();
    // initialize $persons in case nothing is returnd for field
    $persons = false;
    // test queried object to see if it's a post
    if (is_a($queried_object, 'WP_POST')) {
      $persons = get_field('persons', $queried_object->ID);
    // test $persons to make sure something was returned
    if (!empty($persons)) {
      foreach ($persons as $post) {
        ?><meta name="author" content="<?php the_title() ?>" /><?php 
    // if nothing was returned for $persons show a default
    // if this is a single post
    if (!$persons && is_single()) {
      ?><meta name="author" content="<?php echo get_the_author_meta('display_name', $post->post_author); ?>"><?php