Skip to content

Instantly share code, notes, and snippets.

@davekellam
Last active December 20, 2015 17:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davekellam/6168835 to your computer and use it in GitHub Desktop.
Save davekellam/6168835 to your computer and use it in GitHub Desktop.
WordPress Save Debugging
<?php
/**
* Save debug info to log
*
* @param int $post_id ID of the post to save
*/
function dk_debug_save_post( $post_id ) {
global $wpdb;
error_log( print_r( $wpdb->queries, true ) );
}
add_action( 'save_post', 'dk_debug_save_post' );
/**
* Save wp_insert_post debug info to log
*
* @param int $post_id ID of the post to save
*/
function dk_debug_insert_post( $post_id ) {
global $post;
error_log( print_r( $post, true ) );
}
add_action( 'wp_insert_post', 'dk_debug_insert_post' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment