in WordPress

What Does Your WordPress Theme Support?

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

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.

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

if (current_theme_supports('custom-header')) {
  // do something special when custom-header is supported...

if (current_theme_supports('custom-background')) {
  // do something with custom backgrounds

if (current_theme_supports('post-thumbnails')) {
  // do something with post thumbnails

if (current_theme_supports('menus')) {
  // do something with Wordpress menus

if (current_theme_supports('automatic-feed-links')) {
  // do something with your feed links

if (current_theme_supports('editor-style')) {
  // do something with your editor styling

if (current_theme_supports('widgets')) {
  // do something with Wordpress widgets

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email