Last active
January 17, 2019 05:25
-
-
Save insaurabh/a1332a3562e017a8ca51be766c77db14 to your computer and use it in GitHub Desktop.
How to write log in wordpress from child theme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add in child theme function.php | |
// For more info : https://codex.wordpress.org/Debugging_in_WordPress | |
// Step 1 : define( 'WP_DEBUG', true ); | |
// Step 2 : define( 'WP_DEBUG_LOG', true ); | |
// Step 3 : Paste the below code in child theme function.php | |
// Step 4 : Call the function as : hb_write_log('lets debug'); | |
// Step 5 : See the logs @ /website-entry-point/wp-content/debug.log ( if there is no file create a one with same name.) | |
if (!function_exists('hb_write_log')) { | |
function hb_write_log($log) { | |
if (true === WP_DEBUG) { | |
if (is_array($log) || is_object($log)) { | |
error_log(print_r($log, true)); | |
} else { | |
error_log($log); | |
} | |
} | |
} | |
} | |
// call like below. | |
hb_write_log('lets debug') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment