Languages: English • 日本語 Italiano • (Add your language)
Checks a theme's support for a given feature before loading the functions which implement it.
<?php require_if_theme_supports( $feature, $include ); ?>
//alternative of:
<?php if(get_theme_support($feature)) require($include); ?>
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'); ?>
Since: 2.9.0
require_if_theme_supports() is located in wp-includes/theme.php
.
Theme Support:
add_theme_support(),
remove_theme_support(),
current_theme_supports()
Theme Features:
sidebar,
menus,
post-formats,
title-tag,
custom-background,
custom-header,
custom-logo,
post-thumbnails,
automatic-feed-links,
html5,
editor-style,
content_width