Support

Account

Home Forums ACF PRO Unable to Display ACF on Staff Page

Unread

Unable to Display ACF on Staff Page

  • Hey, there! I’m tryng to create a staff page that displays all users with the role “editor” on this website. I’ve got a start here:

    http://annex.gocopilot.org/about/staff/

    Where I’m stumped is how to add the ACF fields I’ve added to the Users. I was able to display them successfully on the “Author Archive” page, but now I’d like to pull in two custom images and a custom field with the job title and everything I’ve tried to pull that data has failed.

    The field names are:
    title
    regpho (a photo array)
    hovpho (a photo array

    Here’s the code in the functions file I’m currently using (you’ll notice I tried to pull in title; however, it’s not displayng at all so there’s certainly something I’m doing wrong! Thanks in advance for your help!

    /*STAFF DIRECTORY*/
    function stadir() {
    ?>
    <?php
    $display_admins = false;
    $order_by = ‘display_name’; // ‘nicename’, ’email’, ‘url’, ‘registered’, ‘display_name’, or ‘post_count’
    $order = ‘DESC’;
    $role = ‘editor’; // ‘subscriber’, ‘contributor’, ‘editor’, ‘author’ – leave blank for ‘all’
    $avatar_size = 161;
    $hide_empty = false; // hides authors with zero posts

    if(!empty($display_admins)) {
    $blogusers = get_users(‘orderby=’.$order_by.’&role=’.$role);
    } else {

    $admins = get_users(‘role=administrator’);
    $exclude = array();

    foreach($admins as $ad) {
    $exclude[] = $ad->ID;
    }

    $exclude = implode(‘,’, $exclude);
    $blogusers = get_users(‘exclude=’.$exclude.’&orderby=’.$order_by.’&order=’.$order.’&role=’.$role);
    }

    $authors = array();
    foreach ($blogusers as $bloguser) {
    $user = get_userdata($bloguser->ID);

    if(!empty($hide_empty)) {
    $numposts = count_user_posts($user->ID);
    if($numposts < 1) continue;
    }
    $authors[] = (array) $user;
    }

    echo ‘<ul id=”grid-contributors”>’;
    foreach($authors as $author) {
    $avatar = get_avatar($author[‘ID’], $avatar_size);
    $author_title = get_field( $author[‘ID’], title );
    $display_name = $author[‘data’]->display_name;
    $author_profile_url = get_author_posts_url($author[‘ID’]);

    echo ‘<li class=”single-item”>’;
    echo ‘<div class=”author-gravatar”>‘, $avatar , ‘</div>’;
    echo ‘<div class=”author-name”>‘, $display_name, ‘</div>’;
    echo ‘<div class=”author-name”>‘, $author_title, ‘</div>’;
    echo ‘‘;
    }
    echo ‘‘;
    ?>
    <?php
    }
    add_action(‘hook_top_stadir’, ‘stadir’);

Viewing 1 post (of 1 total)

The topic ‘Unable to Display ACF on Staff Page’ is closed to new replies.