WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/get theme mod

Description

Retrieves a modification setting for the current theme. Along with set_theme_mod() this function can sometimes offer theme developers a simpler alternative to the Settings API when there is a need to handle basic theme-specific settings.

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

Usage

<?php get_theme_mod$name$default ); ?>

Parameters

$name
(string) (required) Theme modification name.
Default: None
$default
(boolean|string) (optional)
Default: false

Return Values

(string) 

Examples

Calling the Custom Background Color

This example could be used to add the custom background color as a border on the top of the footer. It would be css inserted in the header:

.footer {
     border-top: solid 1px #<?php echo get_theme_mod( 'background_color' ); ?>;
}

Notes

Change Log

Since: 2.1.0

Source File

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

Related

background_color(), set_theme_mod(), get_theme_mod(), get_theme_mods(), remove_theme_mod(), remove_theme_mods()

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