• Resolved purbeckpixels

    (@purbeckpixels)


    I’ve been struggling with what I thought was a bug in the Elementor Page Builder plugin and its interaction with The Events Calendar Shortcode plugin. It turns out that it’s probably the TECS plugin that’s at fault and not Elementor.

    TECS uses wp_reset_query(); on line 368 when I’m pretty sure it should be wp_reset_postdata(); instead. wp_reset_query(); is only required after using query_posts(). TECS uses $wp_query on line 140, which is the global instance of the WP_Query class, thus wp_reset_postdata();should be used. From the WordPress Codex:

    Calling wp_reset_query is not necessary after using WP_Query or get_posts as these don’t modify the main query object. Instead use wp_reset_postdata.

    Replacing wp_reset_query(); with wp_reset_postdata(); fixes the ‘bug’ I had with Elementor and how it was using the current global post in its editing interface.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Brian Hogg

    (@brianhogg)

    I think you’re right! Looks like an early version (before I took it over) used the global $wp_query directly, which would have necessitated the wp_reset_query(), but that’s not the case now. It’s defined at the top but not actually used, it uses tribe_get_events instead.

    The common workaround for Elementor was just adding the shortcode then previewing the page but this solution is much better ?? Still some issues with Elementor and the pro version and the scripts some of the designs use but that’s another story.

    I appreciate the time to find the bug and write a detailed explanation, if you update to version 1.8 once it appears on your dashboard this fix is included. Any issues let me know!

    Thread Starter purbeckpixels

    (@purbeckpixels)

    Thanks for the quick fix. I first encountered this bug last July but thought it was something to do with Elementor, so reported it to them at the time. Today I’ve been testing their latest Release Candidate and came across the bug again (Elementor’s Exit to Dashboard button returned to the wrong WP edit screen on pages containing event listings) so decided to take another look and narrowed it down to TECS. Got there in the end. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Incorrect use of wp_reset_query();?’ is closed to new replies.