Works a treat, thanks very much
That works! thanks a bunch! Only problem: if there is no image, it throws a php error. Is there any way we can get the image conditionally, so that if the image field is empty it displays a default image (or nothing), instead of an error? My code now is this:
<?php
$values = get_field( 'execs','options' );
if ( $values ) {
$execs = array();
foreach ( $values as $value ) {
$link = get_author_posts_url( $value['ID'] ); //get the url
$nicename = $value['display_name'];
$userdesc = $value['user_description'];
$position = get_field( 'academic_position', 'user_' . $value['ID'] ); // custom ACF text
$affiliation = get_field( 'affiliations', 'user_' . $value['ID'] ); // custom ACF text
$pic_object = get_field( 'user_image', 'user_' . $value['ID'] );
$pic = '<img src="' . $pic_object['sizes']['thumbnail']. '" alt="' . $pic_object['alt'] . '" />';
$execs[] = sprintf( '<li><a href="%s">%s</a><p>%s</p><p>%s</p><p>%s</p>%s</li>', $link, $nicename, $userdesc, $position, $affiliation, $pic ); // listing
}
echo '<h4>Executive Committee</h4>';
echo '<ul>';
echo implode( $execs );
echo '</ul>';
}
?>
No answer? Anyone?
Same problem happening here after wp updated to 4.2.1. Nothing has changed, and it worked perfectly before, so I assume this is a bug / incompatibility derived from the upgrade. I am using ACF latest.
Hi,
I am using ACF to add custom fields to the user profiles. One of these custom fields is a Select field with multiple values. This displays fine in the profiles, and the values are saved as expected. What I would like to be able to do is to get these multiple values pulled into the author.php template so that they show in the front end.
I tried to use get_field() and the_field(), but no luck.
Any ideas as to how to display a multiple select from the user’s profile in the author.php template?
Many thanks!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.