add_theme_support() wordpress function and usage This text is not used because the data attribute has a value

add_theme_support() wordpress function and usage

Home / WordPress / WordPress Wiki / add_theme_support() wordpress function and usage

add_theme_support( string $feature, mixed $args )
Registers theme support for a given feature.


Must be called in the theme’s functions.php file to work. If attached to a hook, it must be ‘after_setup_theme’. The ‘init’ hook may be too late for some features.

Example usage:

add_theme_support( 'title-tag' );
add_theme_support( 'custom-logo', array(
    'height' => 480,
    'width'  => 720,
) );



(string) (Required) The feature being added. Likely core values include:

  • ‘admin-bar’
  • ‘align-wide’
  • ‘automatic-feed-links’
  • ‘core-block-patterns’
  • ‘custom-background’
  • ‘custom-header’
  • ‘custom-line-height’
  • ‘custom-logo’
  • ‘customize-selective-refresh-widgets’
  • ‘custom-spacing’
  • ‘custom-units’
  • ‘dark-editor-style’
  • ‘disable-custom-colors’
  • ‘disable-custom-font-sizes’
  • ‘editor-color-palette’
  • ‘editor-gradient-presets’
  • ‘editor-font-sizes’
  • ‘editor-styles’
  • ‘featured-content’
  • ‘html5’
  • ‘menus’
  • ‘post-formats’
  • ‘post-thumbnails’
  • ‘responsive-embeds’
  • ‘starter-content’
  • ‘title-tag’
  • ‘wp-block-styles’
  • ‘widgets’
  • ‘widgets-block-editor’



(mixed) (Optional) extra arguments to pass along with certain features.


(void|false) Void on success, false on failure.

More Information

Features Features

Post Formats

This feature enables Post Formats support for a theme. When using child themes, be aware that

add_theme_support( 'post-formats' )

will override the formats as defined by the parent theme, not add to it.

To enable the specific formats (see supported formats at Post Formats), use:

add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

To check if there is a ‘quote’ post format assigned to the post, use has_post_format():

// In your theme single.php, page.php or custom post type
if ( has_post_format( 'quote' ) ) {
    echo 'This is a quote.';

Post Thumbnails

This feature enables Post Thumbnails support for a theme. Note that you can optionally pass a second argument, $args, with an array of the Post Types for which you want to enable this feature.

add_theme_support( 'post-thumbnails' );
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', 'movie' ) ); // Posts and Movies

This feature must be called before the ‘init’ hook is fired. That means it needs to be placed directly into functions.php or within a function attached to the ‘after_setup_theme’ hook. For custom post types, you can also add post thumbnails using the register_post_type() function as well.

To display thumbnails in themes index.php or single.php or custom templates, use:


To check if there is a post thumbnail assigned to the post before displaying it, use:

if ( has_post_thumbnail() ) {

Custom Background

This feature enables Custom_Backgrounds support for a theme.

add_theme_support( 'custom-background' );

Note that you can add default arguments using:

$defaults = array(
    'default-image'          => '',
    'default-preset'         => 'default', // 'default', 'fill', 'fit', 'repeat', 'custom'
    'default-position-x'     => 'left',    // 'left', 'center', 'right'
    'default-position-y'     => 'top',     // 'top', 'center', 'bottom'
    'default-size'           => 'auto',    // 'auto', 'contain', 'cover'
    'default-repeat'         => 'repeat',  // 'repeat-x', 'repeat-y', 'repeat', 'no-repeat'
    'default-attachment'     => 'scroll',  // 'scroll', 'fixed'
    'default-color'          => '',
    'wp-head-callback'       => '_custom_background_cb',
    'admin-head-callback'    => '',
    'admin-preview-callback' => '',
add_theme_support( 'custom-background', $defaults );

Custom Header

This feature enables Custom_Headers support for a theme.

add_theme_support( 'custom-header' );

Note that you can add default arguments using:

$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' => '',
    'video'                  => false,
    'video-active-callback'  => 'is_front_page',
add_theme_support( 'custom-header', $defaults );

This feature, first introduced in Version_4.5, enables Theme_Logo support for a theme.

add_theme_support( 'custom-logo' );

Note that you can add default arguments using:

add_theme_support( 'custom-logo', array(
    'height'               => 100,
    'width'                => 400,
    'flex-height'          => true,
    'flex-width'           => true,
    'header-text'          => array( 'site-title', 'site-description' ),
    'unlink-homepage-logo' => true,
) );

This feature enables Automatic Feed Links for post and comment in the head. This should be used in place of the deprecated automatic_feed_links() function.

add_theme_support( 'automatic-feed-links' );


This feature allows the use 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', 'style', 'script' ) );

Title Tag

This feature enables plugins and themes to manage the document title tag. This should be used in place of wp_title() function.

add_theme_support( 'title-tag' );

Customize Selective Refresh Widgets

This feature enables Selective Refresh for Widgets being managed within the Customizer. This feature became available in WordPress 4.5. For more on why and how Selective Refresh works read Implementing Selective Refresh Support for Widgets.

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


To show the “Featured Image” meta box in Multisite installation, make sure you update the allowed upload file types, in Network Admin, Network Admin Settings SubPanel#Upload_Settings, Media upload buttons options. Default is jpg jpeg png gif mp3 mov avi wmv midi mid pdf.

Other Notes

The following parameters are read only, and should only be used in the context of current_theme_supports():

  • sidebars: Use register_sidebar() or register_sidebars() instead.
  • menus: Use register_nav_menu() or register_nav_menus() instead.
  • editor-style: Use add_editor_style() instead.

Sample Usage

 * Essential theme supports
 * */
function theme_setup(){
    /** automatic feed link*/
    add_theme_support( 'automatic-feed-links' );
    /** tag-title **/
    add_theme_support( 'title-tag' );
    /** post formats */
    $post_formats = array('aside','image','gallery','video','audio','link','quote','status');
    add_theme_support( 'post-formats', $post_formats);
    /** post thumbnail **/
    add_theme_support( 'post-thumbnails' );
    /** HTML5 support **/
    add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
    /** refresh widgest **/
    add_theme_support( 'customize-selective-refresh-widgets' );
    /** custom background **/
    $bg_defaults = array(
        'default-image'          => '',
        'default-preset'         => 'default',
        'default-size'           => 'cover',
        'default-repeat'         => 'no-repeat',
        'default-attachment'     => 'scroll',
    add_theme_support( 'custom-background', $bg_defaults );
    /** custom header **/
    $header_defaults = array(
        'default-image'          => '',
        'width'                  => 300,
        'height'                 => 60,
        'flex-height'            => true,
        'flex-width'             => true,
        'default-text-color'     => '',
        'header-text'            => true,
        'uploads'                => true,
    add_theme_support( 'custom-header', $header_defaults );
    /** custom log **/
    add_theme_support( 'custom-logo', array(
        'height'      => 60,
        'width'       => 400,
        'flex-height' => true,
        'flex-width'  => true,
        'header-text' => array( 'site-title', 'site-description' ),
    ) );

There needs to be a section for starter content.
This page has good explanation
and this function shows all the default values:

Enabling theme support for align full and align wide option for the block editor, use
add_theme_support( 'align-wide' );

Note that you have to individually call each of these; including multiple ones as an array
add_theme_support( array( 'editor-styles', 'align-wide' ) )

Instead, you must call them individually:

add_theme_support( 'editor-styles' );
add_theme_support( 'align-wide' );

Starter Content #

Defines and registers starter content to showcase themes on new sites.

Starter Content #

Defines and registers starter content to showcase themes on new sites.

add_theme_support( 'starter-content', array(
    // Place widgets in the desired locations (such as sidebar or footer).
    // Example widgets: archives, calendar, categories, meta, recent-comments, recent-posts, 
    //                  search, text_business_info, text_about
    'widgets'     => array( 'sidebar-1' => array( 'search', 'categories', 'meta'), ),
    // Specify pages to create, and optionally add custom thumbnails to them.
    // Note: For thumbnails, use attachment symbolic references in {{double-curly-braces}}.
    // Post options: post_type, post_title, post_excerpt, post_name (slug), post_content, 
    //               menu_order, comment_status, thumbnail (featured image ID), and template
    'posts'       => array( 'home', 'about', 'blog' => array( 'thumbnail' => '{{image-cafe}}' ), ),
    // Create custom image attachments used as post thumbnails for pages.
    // Note: You can reference these attachment IDs in the posts section above. Example: {{image-cafe}}
    'attachments' => array( 'image-cafe' => array( 'post_title' => 'Cafe', 'file' => 'assets/images/cafe.jpg' ), ),
    // Assign options defaults, such as front page settings.
    // The 'show_on_front' value can be 'page' to show a specified page, or 'posts' to show your latest posts.
    // Note: Use page ID symbolic references from the posts section above wrapped in {{double-curly-braces}}.
    'options'     => array( 'show_on_front'  => 'page', 'page_on_front' => '{{home}}', 'page_for_posts' => '{{blog}}', ),
    // Set the theme mods.
    'theme_mods'  => array( 'panel_1' => '{{about}}' ),
    // Set up nav menus.
    'nav_menus'   => array( 'top' => array( 'name' => 'Top Menu', 'items' => array( 'link_home', 'page_about', 'page_blog' )), ),
) );


0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments