HTML Page Element Comments
The THEMECOMMENTS constant is set by the theme according the option in Theme Options -> Skin -> Styles
This will wrap all the main Page Elements in HTML comments indicating start and finish of the element. eg.
<!-- #sidebar -->{Sidebar Output}<!-- /#sidebar -->This helps make things easier to find when viewing the page source or in a browser debug console. 🙂
Of course it adds unnecessary length to the page size so you will want to turn this off in production.
[Value Filter] skeleton_html_comments - return true/false]
Theme Debug Modes
Theme debug mode sets the THEMEDEBUG constant via the themedebug querystring switch (from any site URL.) You can change switch the debug mode on or off, or set it to temporarily output (for that particular page load.)
In practice, you would usually just use ?themedebug=2 or ?themedebug=yes for a specific pageload.
However, to be able to test logged out user content you would need to switch debug mode ON and logout -
or simply view the logged out content from another browser with debug ON and then switch it OFF when done.
Note: You need edit_theme_options capability to toggle or enable/disable debug mode.
Querystring | Alternative | Debug Action | ||
?themedebug=0 | ?themedebug=off | switch theme debug mode off (persistant) | ||
?themedebug=1 | ?themedebug=on | switch theme debug mode on (persistant) | ||
?themedebug=2 | ?themedebug=yes | debug mode on for this pageload (overrides switch) | ||
?themedebug=3 | ?themedebug=no | debug mode off for this pageload (overrides switch) | ||
[Value Filter] | skeleton_theme_debug | return true/false |
When active you debug information will be output to the HTML page source wrapped in HTML comment tags.
Each debug info occurrence will appear in the form of:
<!-- Debug Info Description: {INFO} -->This is so you can search the theme source for a particular 'Info Description' to see what is happening.
Warning: this kind of debug output can prevent Theme Settings or other admin/form/AJAX methods from saving! This is because echoing this information inline means headers are already sent and thus can prevent redirects - causing the Settings API and other things to fail. :-/ So always remember to turn theme debug mode off!
Included Page Templates
You can easily see what page templates are being included on a page (useful for WooCommerce/Forum templates etc.) Simply search for 'Included Template Files' (Debug Info Description) in the page source when debug mode is active. You will find a list of all files included between the wp_loaded and wp_footer action hooks in the page footer.
You can access this page template list more easily (as of v2.0.1) via the dropdown Template menu on the Admin Bar. Hover the submenu items to see full template paths or click the file to load it for viewing in the Theme Editor. (Note: only shows for manage_options capability. You can turn this feature off via Theme Options Muscle Layer -> Admin tab.)
Theme Debug Tracer
A Theme Function Tracer has been developed for running isolated traces within theme files and functions. This is a fast and powerful way of tracking down where something is not behaving in the theme as desired. It allows you to see the flow of all template, function, action and filter calls parsed by the theme as it runs. Memory load and pageload time are also tracked, allowing you to identify possible performance bottlenecks.
To run a trace simply append ?themetrace=1 to any URL on your site to create a trace file. By default trace information is output to your (parent or child) themes /debug/ directory. (Note you need manage_options capability to do a theme trace.) You can also specify further querystrings as in the table below, for example to narrow the scope of the trace, or expand a function trace to log all function arguments passed, or display the trace at the end of the page source.
Querystring | Values | Trace Action | Default | |||||
?themetrace= | 1 or yes | switch to activate theme tracer | off | |||||
&trace= | functions, templates, filters, actions | which resource to trace | all | |||||
&tracedisplay= | 1 or yes | whether output trace display or not | off | |||||
&instance= | string | trace ID used for trace file prefix | timestamp | |||||
&tracecalls= | 1 or yes | whether to trace number of function calls | off | |||||
&traceargs= | 1 or yes | whether to trace function arguments | off | |||||
&tracefunction= | function_name | trace a specific (theme) function | none | |||||
&tracefilter= | filter_name | trace a specific (theme) filter | none | |||||
&traceaction= | action_name | trace a specific (theme) action | none | |||||
&tracetemplate= | loop, sidebar, content, header, footer, comment | trace a (theme) template type | all |
← Previous: Constants and Globals | Back to Documentation Index | Next: → |