0

I am developing WordPress theme with lot of custom code. I am having hard time debugging as I don't know how to print/log messages in order to see them on the standard output i.e. terminal.

WordPress engine is running on OpenShift platform where I connect and look at standard output messages.

2
  • 1
    just add an exit or die() statement after you dump the data. It will display the data and stop the script. Also use var_dump(), it shows more details. happy coding! Commented Jan 16, 2016 at 16:32
  • Possible duplicate of How do I debug a WordPress plugin? Commented Jan 17, 2016 at 3:05

1 Answer 1

1

Try setting define('WP_DEBUG_LOG', true); inside wp-config.php. This causes all errors to also be saved to the /wp-content/debug.log. The flag WP_DEBUG must also be enabled.

Sign up to request clarification or add additional context in comments.

2 Comments

I already have debug logging turned on. How to throw error explicitly ? Or how to make assert statement that will cause the script to break if it is not satisfied ?
The easiest way is the one mentioned by @bwaaaaaa. You can use var_dump($var); method to output any $var. Also place a die; somewhere after that so you can see the results more easily. If you want more advanced debugging you can use xdebug php library. Better to see the instructions of your ide for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.