Types and Views perform complex operations and it’s important to be able to debug its internals.
We’re using an advanced debugger, that can output and tell you what the code is doing.
Enable WordPress Debug
Open your wp-config.php file and change the WordPress debugging mode to TRUE:
This enables the WordPress specific debug system. It will cause all PHP errors, notices and warnings to be displayed. You can read more information about WordPress debugging here.
This PHP messages often contain the name and the line of the file that is causing the bug. This way, you can identify errors coming from one of our plugins.
Debug Output to Console
Add the following to your wp-config.php file:
Then, open the console in your browser. In Google Chrome, click anywhere in the page and click on ‘Inspect element’. Then, click on the ‘Console’ tab.
The console panel shows you everything that happens to display this page.
In this example, it starts by loading the View ‘Todos’. Then, the View tells us that it loaded 3 posts (my 3 todos) and that it’s calling the View Template for each of them. We can see the post ID that’s loaded in each iteration.
More Debug Information
You can get more details debugging information about the query that Views is using by adding the following to your wp-config.php file:
The console will now display details of how the View query is created, the SQL query executed and the posts found.
If you’re debugging something that doesn’t work, we recommend that you first enable debug mode and try it on a View that works as you intend. This will help you understand the debug output better. You can then proceed to the View that you want to debug, and do that much easier.
In case you think that Types or Views are doing something wrong (what we call a bug), you should enable PHP error logging. Again, edit your wp-config.php file and add the following:
ini_set('log_errors',TRUE); ini_set('error_reporting', E_ALL); ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
This will produce a file called ‘error_log.txt’ in your WordPress root directory. Make sure that the web server can create and write this file. If it cannot, use an FTP program to create the file and make it writable to Apache (normally, user www-data).