I have created ACF Fields for Wordpress User page Text and image When I try to display on single.php its not showing nither image or text is showing below is screenshot for refrence.
<ul >
<li>
<div >
<div >
<div >
<?php
$avatar_image= get_field('user_image', 'user_'. $author_id );
?>
<picture>
<img src="<?php echo $avatar_image['url']; ?>" alt="<?php echo $avatar_image['alt']; ?>">
</picture>
</div>
</div>
<div >
<div >
<h5><?php //echo the_field('user_name', 'user_' .$author_id); ?></h5>
</div>
</div>
</div>
</li>
<li>
<i ></i>
<span><?php echo get_the_date('d/m/Y'); ?></span>
</li>
</ul>
CodePudding user response:
You know that in your snippet you have the name text commented out, right? Otherwise you have multiple possible failure points. Off the top of my head:
- Are you sure you're retuning the html as expected (with or without the ACF data)? If not, then you may have the wrong template or other problems. If so:
- Are you sure you have the ACF
user_image
field set to return an array - and in particular for the user you're testing? - Have you tried returning the ACF field by key rather than field name? That sometimes helps.