I think I have seen this problem before and you need to set global $post; on the line before to be able to use setup_postdata($post); as it does not return the $post object, but rather sets it in the global scope.
Related Posts:
- functions.php inject inline css
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Editing or filtering the output of the Genesis navigation
- How to use max and min values of custom fields
- Retrieve tags data in post body
- Run function when WordPress new multisite is created or ACF field is updated
- Having issues with a foreach inside of a shortcode with ACF gallery
- Get Current Post ID in functions php, meta query filter
- ACF not showing
- if statement for wordpress default featured image on single post
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- Add php code to wp_print_scripts?
- Access category within rss2_head hook?
- Can set_post_thumbnail be used to remove a thumbnail?
- get_next_posts_link() returns no result despite available posts
- Programmatically add Yoast meta description after post save
- Compare meta key to current date in pre get post
- Genesis Framework: How to exclude a specific author from archive custom loop
- Insert a field with PREG_REPLACE – strange behaviour
- Perform function on publish AND save (not just save)
- Display ACF category image on archive and single template files
- Featured Image and Tags problem
- Override a Post’s URL with Advanced Custom Fields Function
- WordPress Function Assistance with Loop
- How to show ACF value under post/page title in wp-admin
- How to display an image before title text in menu items
- Filter works on last selection but no others
- How to update an image attachment’s alt text from a custom field when saving a post?
- Help with with my function for wordpress
- ACF Date Form in Custom Admin Field
- Assign IDs to headings in ACF using functions.php
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- get_field() with ID in one signal filter not working
- Echo a String Based On Geolocation? [Woocommerce || ACF]
- Comment function for page
- ACF Filter return value
- Return ACF Field value function
- Providing fallback function and allow override by plugin
- Different body image backgrounds on different pages, posts and categories
- update_post_meta not working in function
- Syling Custom Fields echo’s from from functions.php
- does acf_save_post cause endless loop?
- Call ACF data from functions.php [closed]
- Update post meta with wp cron
- Uploading images via ACF update_field function
- Add button to kitchen sink toggle
- Get User Login Data (date, time… )
- Modify post filter to set custom number of posts per page and exclude child posts
- Remove “Published On” inside wp-admin
- Changing parent element’s class or style
- User function to return multiple get_post_meta()
- How can i unload effect.min.js file?
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- WordPress wraps span tags into p tags
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- why is this function firing on all child menu items as well?
- Custom styles in Tiny MCE with an external CSS file
- I changed Functions.php and now I get “cannot decode raw data NSURLErrorDomain:-1015” (not blank)
- Change WooCommerce add_to_cart Button Text?
- How to modify get_the_excerpt() when post-format equals ‘quote’?
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- Get the alphabetical sorted data with wpdb
- New checkbox in custom widget isn’t saving data
- WordPress Check User Role Function (multiple roles)?
- Post to category based on email domain, for a post-by-email plugin
- struggling with syntax for the_post_thumbnail();
- Echo youtube code from url or shortcode
- WordPress: Highlight search result exact matches
- Woocommerce Default sorting product by product type
- Displaying registered sidebar after post content
- Adding custom social icons to the social media icon block in the Gutenberg editor?
- Allow user select role in wordpress default registration without plugin
- Display link to category over featured image
- Does hook have an effect on increasing the page load?
- Adding a schema code to one specific page using functions.php file
- price of product can’t return when get data of product in functions.php
- Re-style Login Form Whilst Keeping CSS Separate from Frontend CSS
- Can You Set A Minimum Image Dimension For Resizing Images?
- Calling hooks in functions
- Creating a “Related Meta” type field?
- Shortcode with pagination advancing multiple queries
- How to add custom column into custom post, when field is select
- How to add widget in main menu
- Function image_send_to_editor returns emty title tag
- Modified functions.php in Magazine Pro theme of Genesis. 500 error
- Integrate WP Tiles into existing loop (index.php) and theme
- Update functions.php from WordPress dashboard
- How to Add A Rel Filter to All Links?
- Show latest custom post types on dashboard
- Using conditionals, maybe from a DB, to register & enqueue files, for varying pages, in functions.php
- Function working in single.php but not working in custom template file
- Add function to add element on all page
- Function in functions.php by url
- Adding a filter to my posts
- Directing to functions.php the correct way
- display last post modified date in genesis child themes
- comment_post function with js not running
- Simple way to make most of my site private
- custom function works on page.php template but not in functions.php