require_if_theme_supports() WordPress Function

The require_if_theme_supports() function is used to include a file only if the current theme supports a certain feature. This can be useful for child themes that need to include files that the parent theme doesn't include by default.

require_if_theme_supports( string $feature, string $include ) #

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


Parameters

$feature

(string)(Required)The feature being checked. See add_theme_support() for the list of possible values.

$include

(string)(Required)Path to the file.


Top ↑

Return

(bool) True if the active theme supports the supplied feature, false otherwise.


Top ↑

Source

File: wp-includes/theme.php

function require_if_theme_supports( $feature, $include ) {
	if ( current_theme_supports( $feature ) ) {
		require $include;
		return true;
	}
	return false;
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More