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?
- 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?
- How to retrieve a value from get_posts()? [closed]
- How to get the registered sidebar’s name by its id?
- How do I create a drop down menu in a widget?
- WordPress widget in custom theme
- How to allow PHP In WordPress text widget
- display most popular tags in two columns
- Display 4 chronological posts starting with a random post
- 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
- 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
- Add before_content and after_content to register_sidebar
- 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
- WordPress widget/sidebar dividers?
- Create onClick Event to Re-load a Widget
- How to put a variable in a instance in the widget
- How to output widget
- Extending the WP_Widget_Text class
- Logged in user ID as post ID
- How to make my custom widget appear within WordPress widgets? Plugin development
- get widget number from array dynamically
- Adding widgets to my plugin page instead of WordPress dashboard
- Open post-content in archive page in a Modal box with bootstrap
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Why my image upload button is not working in wordpress widget area?
- Adding a widget function into the php theme file
- Query if audio attachment AND/OR custom field
- If has $title in widgets
- Show latest posts in a plain HTML website custom widget [closed]
- How to determine if the sidebar is empty? Or not active?
- How to make widget title accept php?
- PHP Syntax Error on get_posts
- Is it bad to add html to a widget by closing and reopening the php tags?
- Widget back end radio button issue
- How to retrive the text : No movie by this actor
- Correctly Using checked function of WordPress
- 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
- How to use title attributes in sidebar widget?
- display specific widget to a page
- Dynamically display font icons in widget
- Correct code to use php in text widget
- random reason on refresh
- Add a select-option to the default widgets
- Stuck with sidebar registering
- Don’t display a sidebar widget when on a specific page
- Some problems in custom widget
- WordPress 6.0 class-wp-widget.php fatal errors in PHP 8.1.6
- How to get woocommerce orders with get_posts method in a shortcode
- How do you create a custom category widget that you can style?
- How to use wp_get_attachment_image or wp_get_attachment_image_src instead of $instance[‘single_feature_image_uri’]
- Loading Widgets Via Child Theme
- Inserting a class on before_widget if checkbox is checked
- Current WordPress Page Title as Search Parameter into A Tag
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- dashboard widget form not submit mails
- Add widget area from visual editor
- How can I render more than multiple posts on template-parts with post formats
- How to make a “page-option” in WordPress
- Priority call methods – PHPMailer->addAddress(NULL)
- I need to edit a widget, with no dashboard access
- Dynamic_sidebar load in string makeup
- missing admin bar and widget in a template
- My own theme’s custom widget areas are not working
- Add disclaimer before certain posts and pages
- 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?
- Create a hierarchical loop at predefined markup requirements
- 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
- Update title of every instance of widget using text field
- Are widget arguments always set inside My_Widget::widget()?
- WordPress – registering sidebar and adding a button directly after .textwidget
- Sort posts by title, sort array by largest number [duplicate]
- Using existing widget code! [closed]
- 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
- 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
- WP Debug enabled Undefined index error in a widget
- 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