How to add Features in WordPress using add_theme_support Function

In order to register support for certain theme features in WordPress the Add Theme Support (add_theme_support) function needs to be utilized. This powerful function is used by almost all themes, so if you’re a WordPress developer it’s definitely a good idea to familiarize yourself with it and its available features. In this tutorial we will teach you how to add features in WordPress using the Add Theme Support function.

The Base Function

In order to add features in WordPress, we will need to add a PHP filter to the WordPress functions file. Open your functions.php file then copy and paste the code below. This will be the base code to which all features requiring support will be added inside of.

PHP

if ( function_exists( 'add_theme_support' ) ) { 
    YOUR FEATURES GO HERE
}

Post Thumbnails

Add one or more of these features to enable support for post thumbnails.

EVERYWHERE

add_theme_support( 'post-thumbnails' );

ONLY PAGES

add_theme_support( 'post-thumbnails', array( 'page' ) );

ONLY POSTS

add_theme_support( 'post-thumbnails', array( 'post' ) );

ONLY CUSTOM POST TYPES

add_theme_support( 'post-thumbnails', array( 'your-post-type-name' ) ); 

Custom Background

Add this feature in order to enable support for custom backgrounds.

add_theme_support( 'custom-background' );

Custom Header

Add this feature in order to enable support for custom headers.

add_theme_support( 'custom-header' );

Custom Logo

Add this feature in order to enable support for a custom logo.

add_theme_support( 'custom-logo' );

Feed Links

Add this feature in order to enable support for automatic feed links for post and comment in the head.

add_theme_support( 'automatic-feed-links' );

HTML5

Add this feature in order to enable support for the usage of HTML5 markup for the search forms, comment forms, comment lists, gallery, and caption.

add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );

Title Tag

Add this feature in order to enable plugins and themes to manage the document title tag.

add_theme_support( 'title-tag' );

Customize Selective Refresh Widgets

Add this feature in order to enable selective refresh for widgets being managed within the Customizer.

add_theme_support( 'customize-selective-refresh-widgets' );

Visit WordPress.org to Learn More

Add Theme Support Function on WordPress.org

Troubleshooting

If you are having problems getting this tutorial to work please reread the tutorial and try again, if you still cannot get it to work please leave us a comment below and we will respond as soon as possible. Please do not email us with problems regarding this tutorial, only comments will be responded to.