Tuns out it needed: global $post
Complete working code:
<div class="aboutgridcont">
<ul class="about-us-grid">
<li>
<?php
global $post;
$posts = get_posts('post_type=employee&orderby=rand&numberposts=16'); foreach($posts as $post) { ?>
<img class="headshot" src="https://wordpress.stackexchange.com/questions/196622/<?php the_field("headshot'); ?>">
<?php } ?>
</ul>
</div>
Related Posts:
- How to include checkbox in widget backend form?
- Only get_posts of certain post formats
- Limit the number of inactive widgets
- Create Image Uploader for Widget
- Displaying a variable stored in functions.php inside widget
- Check if widget has content
- Transform php code into a widget?
- Getting movie and serial on actor page
- WordPress widget in custom theme
- how to display active, upcoming and past event with featured listing with pagination
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- List authors with posts in a category
- Display 4 chronological posts starting with a random post
- How to add Shortcode (font awesome) in widget title?
- Anything I can add to functions.php to make text widgets accept PHP?
- WordPress menu deletes when trying to add a hook
- dynamic sidebar not showing anything
- How can I add a specific, custom widget to my theme’s header.php?
- Get widget settings function?
- Widgets not showing in my custom theme
- javaScript in section of WP API
- Style every second widget?
- How to group 2 radio buttons in a widget?
- PHP Deprecated: WP_RSSjb has a deprecated constructor
- Advanced Custom Fields: Post Object – Not returning data [closed]
- custom widget on the footer
- Missing sidebar parameter “fix” – before_content
- How to add just one specific page to widget without plugin?
- Why not yield/iterable in posts interface?
- Dynamic Sidebars & Echo
- How do I exclude recent post from recent post php widget
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- Open post-content in archive page in a Modal box with bootstrap
- Hide subcategories (widget)
- Why my image upload button is not working in wordpress widget area?
- Adding a widget function into the php theme file
- How to edit widget code to add unique class name to each div?
- How do I get post attachments in menu_order in WordPress?
- Archives shortcode displaying above widget title
- Widgets in the loop if active
- How to make widget title accept php?
- How i can get post data from database when i am getting post id from url in wordpress
- Hook called before text widget save
- How to retrive the text : No movie by this actor
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- How to get post category list as select in front-end?
- Simple php in wordpress widget [closed]
- Unable to render custom field after attempt to generate a list of recent post in page template
- Show different website layout if no sidebar added
- random reason on refresh
- Add a select-option to the default widgets
- Add class to every other posts using get_posts
- Don’t display a sidebar widget when on a specific page
- Some problems in custom widget
- search.php to search only the post title
- get value from get_post_meta then reuse it in another get_post_meta
- How do you create a custom category widget that you can style?
- How a HTML form can trigger a PHP function?
- Retrieve the whole widget sidebar and pass it inside an html
- How to use wp_get_attachment_image or wp_get_attachment_image_src instead of $instance[‘single_feature_image_uri’]
- How to stop hiding buttons forward / backward in pagination?
- How to create a widget with a populated dropdown?
- dashboard widget form not submit mails
- Add widget area from visual editor
- Priority call methods – PHPMailer->addAddress(NULL)
- is_user_logged_in() not working in homepage
- Dynamic_sidebar load in string makeup
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- Featured Products not showing up in “Featured” area of homepage
- How to display post_content from database in different on template page?
- Displaying POST content with HTML tags and all
- (Who to follow) Twitter widget
- Widget Logic – display on page and all child
- Add disclaimer before certain posts and pages
- Widget Update problems using a for loop
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- How to list categories by page id in wordpress
- Non-static method error when trying to use class in widgets
- offset and max_num_pages in pagination gallery
- Are WordPress widgets cached?
- Slider from different widgets
- Update title of every instance of widget using text field
- Are widget arguments always set inside My_Widget::widget()?
- WP_Widget dynamic field array with external AJAX
- List sibling pages widget, exclude current page
- Sort posts by title, sort array by largest number [duplicate]
- Name Input from widget displays Sidebar name instead of saved data
- WordPress – show number of comments for each post in widget
- Widget header unique classes
- Transient Loop Not working as expected
- My custom widget won’t stay in the widget area after I refresh the widget page
- key( $GLOBALS[‘wp_registered_sidebars’] ) is always showing the same value
- show/hide attachments
- PHP Widget and do_shortcode
- Edit the Publish Widget Options
- How to define template directory in this widget code
- WP Debug enabled Undefined index error in a widget
- Find owner of coupon
- How to edit a widget code?