Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MT | TEC | Tribe Query Debug
<?php
// Checks the URL for the debug parameter
// example.com/event/event-name/?tribe_query_debug=true
function tribe_events_pre_get_posts_dumper ($query) {
$show_debug_info = isset($_GET['tribe_query_debug']) ? $_GET['tribe_query_debug'] : false;
if(($show_debug_info == "true" && $query->is_main_query() === true) || $show_debug_info == "full") {
echo "<h3>&lt;Tribe Events Query&gt;</h3>";
tribe_spit_it_out($query);
add_filter('the_posts', 'tribe_dump_return_query', 100, 1);
}
}
add_action('pre_get_posts', 'tribe_events_pre_get_posts_dumper');
function tribe_dump_return_query($query) {
echo '<p>Query Results:</p>';
tribe_spit_it_out($query);
echo '<p>is_404() = </p>';
var_dump(is_404());
echo '<h3>&lt;/Tribe Events Query&gt;</h3>';
// Only run this once
remove_filter('the_posts', 'tribe_dump_return_query', 100, 1);
return $query;
}
function tribe_spit_it_out($var_for_dumping) {
echo '<pre>';
var_dump($var_for_dumping);
echo '</pre>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.