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
- Is the first item returned by get_posts() always the latest post?
- How display widget by id
- Why can I not use setup_postdata($post) in the sidebar?
- Create Image Uploader for Widget
- How to retrieve a value from get_posts()? [closed]
- How to get the registered sidebar’s name by its id?
- Displaying a variable stored in functions.php inside widget
- Check if widget has content
- Transform php code into a widget?
- How do I create a drop down menu in a widget?
- Getting movie and serial on actor page
- WordPress widget in custom theme
- How to allow PHP In WordPress text widget
- 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
- display most popular tags in two columns
- 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?
- Show Specific Footer Widget for Specific Pages
- WordPress menu deletes when trying to add a hook
- dynamic sidebar not showing anything
- PHP contact form returns warning in text widget [closed]
- 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
- Class ‘WP_Widget’ not found
- How do I output a database option that is an array into a get_posts array?
- nowplaying.include.php Will Not Display Results
- javaScript in section of WP API
- Style every second widget?
- How to group 2 radio buttons in a widget?
- Add before_content and after_content to register_sidebar
- PHP Deprecated: WP_RSSjb has a deprecated constructor
- I can’t get my custom widget area to show on my WordPress site
- How to run PHP code in Text Widget with no plugin in WP 4.4
- Advanced Custom Fields: Post Object – Not returning data [closed]
- WordPress widget/sidebar dividers?
- custom widget on the footer
- Missing sidebar parameter “fix” – before_content
- How to add just one specific page to widget without plugin?
- Create onClick Event to Re-load a Widget
- How to put a variable in a instance in the widget
- Why not yield/iterable in posts interface?
- How to output widget
- Extending the WP_Widget_Text class
- Dynamic Sidebars & Echo
- 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
- My own theme’s custom widget areas are not working
- 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’?
- Beyond widget side menu editing, with the php page, custom template
- How to list categories by page id in wordpress
- PHP: Why does my code work in index.php but not a widget?
- Non-static method error when trying to use class in widgets
- Create a hierarchical loop at predefined markup requirements
- offset and max_num_pages in pagination gallery
- Are WordPress widgets cached?
- Widget edit and add in any page
- widget: input the px value from user and use it as inline style in widget function
- Slider from different widgets
- Update title of every instance of widget using text field
- how to run a php code in widget?
- Are widget arguments always set inside My_Widget::widget()?
- WP_Widget dynamic field array with external AJAX
- WordPress – registering sidebar and adding a button directly after .textwidget
- 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
- Using existing widget code! [closed]
- Widget header unique classes
- Banner editable from backend
- 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
- How to change links in the 3 main categories, on widget category, to a javascript function call
- Using a loop to build and update widgets
- 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 check elementor is widget is active or loaded
- How to edit a widget code?
- Link on post title only if post have content
- WordPress PHP8.2 Critical Error in class-wp-widget.php
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y
- How to make posts_like_dislike reference current post when iterating?
- Category Attachment Pagination 404 Error on 2nd Page
- Trying to insert widget code into theme function