In my functions.php
I have the following:
add_theme_support( 'post-thumbnails', 'html5', array( 'comment-list', 'comment-form', 'search-form' ) );
…which in WP 3.8.1 disables e.g. featured image (i.e. post-thumbnails
).
My question is how to properly format all these support items in the add_theme_support
function; is adding two separate function calls right or ‘wrong’?
add_theme_support( 'post-thumbnails' );
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form' ) );
You need to use one
add_theme_support()
call for each feature. Per the Codex, the proper function call is:add_theme_support( $feature, $arguments );
as you can see have two parameters,$feature
and$arguments
.$feature
is the feaure you need to add theme support for. This parameter doesn’t accept an array, only a string.So you would have to add a
add_theme_support
for every feauture that you would like to include in your theme. In your question, it is correct to use and the correct way to use two separate instances ofadd_theme_support
.A point of note, I always use add
add_theme_support
inside my theme setup function and then add that function to theafter_setup_theme
action hook.If you check the source …
… it is clear that
add_theme_support()
accepts a string, and only a string, for the$feature
parameter. It doesn’t check for, nor loop over, an array of values, so you must call this function each time you need it.You could of course create your own loop to ease the pain, which is what I’d do:
Note: That code is not thoroughly tested but throws no
Notice
s when I run it and reading the source makes me think it should work without issue.That
func_num_args()
part on lines 1354 to 1377, by the way, is how you can have two arguments as per the Codex but only one in the function definition. For example (for the curious):