I have created a field within the wordpress profile (created with a plugin called Advanced Custom Fields) which allows customers to upload their logo. I would like to now loop through all those customers and display that logo (in a list preferably)

Here are some attempts, can someone guide me to the right direction:

<?php
    $args = get_users( array( 'fields' => array( 'display_name' ) ) );
    $loop = new WP_Query( $args );
        while ( $loop->have_posts() ) : $loop->the_post();
            echo '<li>';
            echo '<img src="';
            the_field('company_logo');
            echo '" alt="';
            the_field('company_name');
            echo '"/>';
            echo '</li>';
        endwhile;

Here is another attempt

        <?php
            $blogusers = get_users( array( 'fields' => array( 'display_name' ) ) );
            $variable = get_field('company_logo', $blogusers);
            foreach ( $blogusers as $user ) {
                echo the_field('company_logo', $blodusers);
            }
        ?>

Another

<?php
    $blogusers = get_users('orderby=company_name');
    $author_id = get_the_author_meta( 'ID' );
    $image1 = get_field('company_logo', 'user_'. $author_id );
        $image2 = get_field('company_name', 'user_'. $author_id );
    foreach ($blogusers as $author_id) {
            echo '<li><div class="image_wrapper"><img class="profile1" src="';
            echo $image1['url'];
            echo '"/></div><img class="profile2 hoverShow" src="';
            echo $image2['url'];
            echo '"/><div class="imageOverlay"><p>';
            echo '</p></div></li>';
    }
?>

None of the above are showing any results apart from the HTML echos’

Thanks in advance

Read more here: Advanced Custom Fields (Loop user profile field)


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: