Functions for troubleshooting wordpress themes :: 2018-01-17 14:31:24

Here are some functions that will aid in diagnosing theme issues.
The first(SFC_show_template) will reveal which php script was called (great for dealing with templates).
The second(SFC_get_post_formats), will reveal all the ‘post formats’ supported in ‘theme_support(“post-formats’)’.
The third(SFC_show_theme_support), will relay if built in theme support has been installed.
Add them both to functions.php, call the SFC_show_theme_support() function in another file where you will define and add arguments there. $SFC_theme_supports is an array that you would define to use as arguements to the function. SFC_get_post_formats() and SFC_show_template() need no arguments.


add_theme_support( 'post-formats' );


$SFC_theme_supports = array(
'post-thumbnails',
'post-formats',
'custom-header',
'custom-background',
'menus',
'automatic-feed-links',
'editor-style',
'widgets',
'html5',
'title-tag'
);


function SFC_show_template() {
global $template;
echo "Theme template: ".basename($template) ."<br/>";
}


/**
A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post.
**/
function SFC_get_post_formats(){
if ( current_theme_supports( 'post-formats' ) ) :
$SFC_post_formats = get_theme_support( 'post-formats' );
if ( is_array( $SFC_post_formats[0] ) ) :
foreach($SFC_post_formats[0] as $SFC_post_format) :
echo $SFC_post_format." 'post_format' is supported...<br/>";
endforeach;
endif;
endif;
}


function SFC_show_theme_support($SFC_array) {
foreach($SFC_array as $SFC_theme_item):
if (current_theme_supports($SFC_theme_item)) :
echo $SFC_theme_item." 'theme_support' is supported...<br/>";
endif;
endforeach;
}

« »