WordPress at a glance

get_theme_mod() WP 1.0

Retrieve theme modification value for the current theme.

If the modification name does not exist, then the $default will be passed through sprintf() PHP function with the first string the template directory URI and the second string the stylesheet directory URI.

Works based on: get_theme_mods()
✈ 1 time = 0.000035s = very fast | 50000 times = 0.58s = very fast PHP 7.0.5, WP 4.5
Hooks from function:
Return

String.

Usage

get_theme_mod( $name, $default );
$name(string) (required)
Theme modification name.
$default(true/false/string)

Default: false

Code of get_theme_mod: wp-includes/theme.php VER 4.9.8

<?php
function get_theme_mod( $name, $default = false ) {
	$mods = get_theme_mods();

	if ( isset( $mods[$name] ) ) {
		/**
		 * Filters the theme modification, or 'theme_mod', value.
		 *
		 * The dynamic portion of the hook name, `$name`, refers to
		 * the key name of the modification array. For example,
		 * 'header_textcolor', 'header_image', and so on depending
		 * on the theme options.
		 *
		 * @since 2.2.0
		 *
		 * @param string $current_mod The value of the current theme modification.
		 */
		return apply_filters( "theme_mod_{$name}", $mods[$name] );
	}

	if ( is_string( $default ) )
		$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );

	/** This filter is documented in wp-includes/theme.php */
	return apply_filters( "theme_mod_{$name}", $default );
}

Related Functions

From tag: Theme Modification API (theme mods options settings)

More from category: Other Theme Functions

No comments
    Hello, !     Log In . Register