Toolset plugins 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.
Since Views 1.5 we have a nice debug tool that can be used to check what is happening on a page containing Views or Content Templates. To enable it, go to Views -> Settings and look for the section Debug mode:
By default, the debug tool is disabled. Once enabled, you will be able to chose between to modes:
The Views debug tool will show the results of its analysis in a popup window that will open when you visit a page of your site containing a View or Content Template. We know that some browsers block that kind of popups from being opened, so we provide a nice test to check your browser settings. In case you need it, here you can find instructions for allowing popups on specific sites for the major browsers: Mozilla Firefox, Internet Explorer, Google Chrome, Opera.
In the popup generated by the debug tool, you will see a lot of information:
This way, you will have all the information needed to see what is happening at every moment.
There are two options in that debug popup:
You can also use a more generic debug tool included in Views that will display some information in the browser console.
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.
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 Content Template for each of them. We can see the post ID that’s loaded in each iteration.
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).