Shortcode not resetting query
-
When we are using the shortcode [show_testimonials], and also filtering the title, the title becomes the final testimonial title, instead of the page it resides on.
After troubleshooting, we discovered that on the shortcode portion, you have a query, but you don’t reset the postdata, so once the shortcode is run, the global title for get_the_title() is the title of the last testimonial.
To fix this, at the end of the shortcode, I added “wp_reset_postdata()”:
endwhile; $result .= '</ul>'; wp_reset_postdata(); return $result;
This fixed the issue for me, and you may want to include this fix on a future release.
- The topic ‘Shortcode not resetting query’ is closed to new replies.