Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fadingdust/cb72c25b6ac0c66a98f8dd4a4e9c400e to your computer and use it in GitHub Desktop.
Save fadingdust/cb72c25b6ac0c66a98f8dd4a4e9c400e to your computer and use it in GitHub Desktop.
Add an HTTP header on Wordpress REST API responses showing the number of MySQL Queries performed
<?php
// Add the Number of queries to the header, because I'm a nerd.
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'X-Query-Count: '.intval( get_num_queries() ) );
return $value;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment