Fatal Error with WP Query
-
There is a bug with the latest version of TEC that doesn’t play nice with the main WP query. There are multiple people on here reporting it however without a lot of details so hopefully this helps resolve the bug. If you have a standard WP query like below it throws an error like so.
Fatal error: Uncaught Error: Call to a member function is_main_query() on null in D:\Websites\momentum\wp-content\plugins\the-events-calendar\src\functions\template-tags\general.php:1694 Stack trace: #0 D:\Websites\momentum\wp-content\plugins\the-events-calendar\src\Tribe\Query.php(163): tribe_is_events_front_page() #1 D:\Websites\momentum\wp-includes\class-wp-hook.php(286): Tribe__Events__Query::parse_query(Object(WP_Query)) #2 D:\Websites\momentum\wp-includes\class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #3 D:\Websites\momentum\wp-includes\plugin.php(515): WP_Hook->do_action(Array) #4 D:\Websites\momentum\wp-includes\class-wp-query.php(1006): do_action_ref_array(‘parse_query’, Array) #5 D:\Websites\momentum\wp-includes\class-wp-query.php(1621): WP_Query->parse_query() #6 D:\Websites\momentum\wp-includes\class-wp-query.php(3222): WP_Query->get_posts() #7 D:\Websites\momentum\wp-includes\class-wp-query.php(3328): WP_Query->query(Array) #8 D:\Websites\momentum\wp-content\themes\momentum\parts\home-blog-excerp in D:\Websites\momentum\wp-content\plugins\the-events-calendar\src\functions\template-tags\general.php on line 1694
<?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query( array( 'posts_per_page' => 4, 'paged' => $paged ) ); ?> <?php if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <article <?php post_class('BlogIntroWrap'); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting"> <?php the_excerpt(); ?> </article> <!-- /article --> <?php endwhile; endif; ?> <?php $wp_query = null; $wp_query = $temp; ?> <?php wp_reset_postdata(); ?>
The topic ‘Fatal Error with WP Query’ is closed to new replies.