Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work
I am using ACF as related posts. I have the following code.
?php $post_objects = get_field('repeater_related_items');
if( $post_objects ): ?
ul
?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?
?php setup_postdata($post); ?
li
a href="?php the_permalink(); ?"?php the_title(); ?/a
span?php the_field('repeater_related_items'); ?/span
/li
?php endforeach;?
/ul
?php wp_reset_postdata(); ?
?php endif;?
?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Main Sidebar') ) : endif; ?
The problem is that when I add this to sidebar other widget doesn't work.
Topic wp-reset-query wp-reset-postdata query-posts Wordpress
Category Web