How do i get to the console log in wordpress?
You can write a utility function like this:
The you may call the function like this:
and this will output to console like this:
Notice the quotes replaced with "-". It is done so that message does not mess up your script as pointed by @Josef-Engelfrost You may also go one step further and do something like this:
and call the function like this:
It will output error in console. Debugging PHP can be a pain in WordPress. Add this handy code snippet to your theme’s
Kevin Dees is a speaker, entrepreneur, blogger, and developer. He’s best known for his work in WordPress and podcasting for the retired SitePoint show. Kevin has developed sites for the brands Verizon, Denny’s, RIDGID, Michelin, and others. Currently, he is working on TypeRocket which powers over 10,000 professional websites and products internationally. See all posts by Kevin Dees
How to add PHP Console Log in Wordpress - Data
How to access the console on WordPress?Accessing the WordPress console via the URL /wp-admin
By default, you just need to add /wp-admin to the end of your domain name's URL into the to access the WordPress console directly.
How do I log into PHP console?Using json_encode function
$js_code = 'console. log(' . json_encode($output, JSON_HEX_TAG) . You can call this function at the exact place you want to run the console_log that we just created above.
|