WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/require if theme supports

Description

Checks a theme's support for a given feature before loading the functions which implement it.

Usage

<?php require_if_theme_supports$feature$include ?>

Parameters

$feature
(string) (required) the feature being checked
Default: None
$include
(string) (required) the file containing the functions that implement the feature
Default: None

Return Values

(boolean) 
This function returns a boolean (true|false).

Examples

Let's assume you would like to support a custom feature 'my_theme_feature' in your theme. That feature is implemented in the file my-feature.php and enabled when the feature was registered by add_theme_support(). The next code will load my-feature.php from theme's directory when a feature 'my_theme_feature' was registered.

<?php
    require_if_theme_supports('my_theme_feature', get_template_directory() . '/my-feature.php');
?>

Notes

Change Log

Since: 2.9.0

Source File

require_if_theme_supports() is located in wp-includes/theme.php.

Related

Theme Support: add_theme_support(), remove_theme_support(), current_theme_supports()
Theme Features: sidebar, menus, post-formats, title-tag, custom-background, custom-header, post-thumbnails, automatic-feed-links, html5, editor-style, content_width

See also index of Function Reference and index of Template Tags.