Theme Development

What Does Your WordPress Theme Support?

By default your WordPress themes will support a number of features like these:

  • Custom headers
  • Custom Backgrounds
  • Post Thumbnails
  • Menus
  • Automatic Feed Links
  • Editor Style
  • Widgets

Before WordPress 3.4 you needed to register these different feature separately, but now with 3.4 with can use the WordPress function add_theme_support().

Business WordPress Theme - ThemeForest Previewer

Enable Custom Headers

Before WordPress 3.4 you needed to use the WordPress function add_custom_image_header(). But now in 3.4 to turn on Custom Headers on you form all you need to do is pass in the paraemter custom-header to add_theme_support();

add_theme_support( 'custom-header' );

The second parameter is optional but it allows you to set a number of different options on the image such as size.

$defaults = array(
	'default-image'          => '',
	'random-default'         => false,
	'width'                  => 0,
	'height'                 => 0,
	'flex-height'            => false,
	'flex-width'             => false,
	'default-text-color'     => '',
	'header-text'            => true,
	'uploads'                => true,
	'wp-head-callback'       => '',
	'admin-head-callback'    => '',
	'admin-preview-callback' => '',
);
add_theme_support( 'custom-header', $defaults );

Enable Custom Background

The same with Custom backgrounds before version 3.4 you needed to use the function add_custom_background() but now you can just use the same function as custom header add_theme_support().

add_theme_support( 'custom-background' );

Again the parameters you pass into this function will allow you to set the options to the background image.

$defaults = array(
	'default-color'          => '',
	'default-image'          => '',
	'wp-head-callback'       => '_custom_background_cb',
	'admin-head-callback'    => '',
	'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $defaults );

Enable Post Thumbnail

By default you can set the featured image on the post but you would now be able to use the function the_post_thumbnail if the theme does not support post thumbnails.

To enable post thumbnails on your WordPress theme you need to turn it on by using the following function.

add_theme_support( 'post-thumbnails' );

It is possible to just turn on post thumbnails for different post types, for example if you just want thumbnails turned on for posts or pages or custom post types then you can pass through this value as the second parameter.

add_theme_support( 'post-thumbnails', array( 'post' ) );          // Posts only
add_theme_support( 'post-thumbnails', array( 'page' ) );          // Pages only
add_theme_support( 'post-thumbnails', array( 'post', 'custom-post' ) ); // Posts and custom-post

Now these are turned on you can display the thumbnails by using the function the_post_thumbnail().

if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  the_post_thumbnail();
}

Post Thumbnail Size

the_post_thumbnail('thumbnail');       // Thumbnail (default 150px x 150px max)

Post Medium Size

the_post_thumbnail('medium');          // Medium resolution (default 300px x 300px max)

Post Large Size

the_post_thumbnail('large');           // Large resolution (default 640px x 640px max)

Post Other Sizes

the_post_thumbnail( array(100,100) );  // Other resolutions

To automatically add a link around the post thumbnail you can do this by using this tutorial.

Add Link Around Post Thumbnail

Enable Automatic Feed Links

Wordpress allows your visitors to easily subscribe to your RSS feeds by adding the link in the head tag of your theme. To turn this feature on you need to use the following function.

add_theme_support( 'automatic-feed-links' );

Check To See What Your Theme Supports

If you are writing plugins then you need to make sure what the current theme supports before you can do something on the theme.

To check if your current theme supports one of the following:

  • Custom headers
  • Custom Backgrounds
  • Post Thumbnails
  • Menus
  • Automatic Feed Links
  • Editor Style
  • Widgets

You can use the WordPress function current_theme_supports().

<?php 
if (current_theme_supports('custom-header')) {
  // do something special when custom-header is supported...
}
?>

<?php 
if (current_theme_supports('custom-background')) {
  // do something with custom backgrounds
}
?>

<?php 
if (current_theme_supports('post-thumbnails')) {
  // do something with post thumbnails
}
?>

<?php 
if (current_theme_supports('menus')) {
  // do something with WordPress menus
}
?>

<?php 
if (current_theme_supports('automatic-feed-links')) {
  // do something with your feed links
}
?>

<?php 
if (current_theme_supports('editor-style')) {
  // do something with your editor styling
}
?>

<?php 
if (current_theme_supports('widgets')) {
  // do something with WordPress widgets
}
?>
Back to top

Fastest WordPress Hosting With WPEngine

Stunning speed, powerful security, and best-in-class customer service. At WP Engine.

Risk free for 60 days