I have the following code in a template, it and displays images form a custom field:
<ul class="about-us-grid">
<li>
<?php $posts = get_posts('post_type=employee&orderby=rand&numberposts=16'); foreach($posts as $post) { ?>
<img class="headshot" src="<?php the_field('headshot'); ?>">
<?php } ?>
</ul>
It works in a pagetemplate.php file but when I place it into a widget, it doesn't pull the php data. I'm using PHP Code Widget. I've tried several other PHP widget plugins as well, so I don't thats the issue. Do I have to code this differently for it work in a widget versus a template?