set_theme_mod

The timeline below displays how wordpress function set_theme_mod has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Updates theme modification value for the active theme.
 *
 * @since 2.1.0
 * @since 5.6.0 A return value was added.
 *
 * @param string $name  Theme modification name.
 * @param mixed  $value Theme modification value.
 * @return bool True if the value was updated, false otherwise.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filters the theme modification, or 'theme_mod', value on save.
     *
     * 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 3.9.0
     *
     * @param mixed $value     The new value of the theme modification.
     * @param mixed $old_value The current value of the theme modification.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    return update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 5.9

/**
 * Updates theme modification value for the current theme.
 *
 * @since 2.1.0
 * @since 5.6.0 A return value was added.
 *
 * @param string $name  Theme modification name.
 * @param mixed  $value Theme modification value.
 * @return bool True if the value was updated, false otherwise.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filters the theme modification, or 'theme_mod', value on save.
     *
     * 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 3.9.0
     *
     * @param mixed $value     The new value of the theme modification.
     * @param mixed $old_value The current value of the theme modification.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    return update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 5.6

/**
 * Updates theme modification value for the current theme.
 *
 * @since 2.1.0
 * @since 5.6.0 A return value was added.
 *
 * @param string $name  Theme modification name.
 * @param mixed  $value Theme modification value.
 * @return bool True if the value was updated, false otherwise.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filters the theme modification, or 'theme_mod', value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme modification.
     * @param string $old_value The current value of the theme modification.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    return update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 5.5

/**
 * Updates theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name  Theme modification name.
 * @param mixed  $value Theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filters the theme modification, or 'theme_mod', value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme modification.
     * @param string $old_value The current value of the theme modification.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 5.3

/**
 * Update theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name  Theme modification name.
 * @param mixed  $value Theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filters the theme modification, or 'theme_mod', value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme modification.
     * @param string $old_value The current value of the theme modification.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 4.6

/**
 * Update theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name  Theme modification name.
 * @param mixed  $value Theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filters the theme mod value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme mod.
     * @param string $old_value The current value of the theme mod.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 4.3

/**
 * Update theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name  Theme modification name.
 * @param mixed  $value Theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filter the theme mod value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme mod.
     * @param string $old_value The current value of the theme mod.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 4.2

/**
 * Update theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name Theme modification name.
 * @param mixed  $value theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filter the theme mod value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme mod.
     * @param string $old_value The current value of the theme mod.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 4.1

/**
 * Update theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name Theme modification name.
 * @param string $value theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filter the theme mod value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme mod.
     * @param string $old_value The current value of the theme mod.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 3.9

/**
 * Update theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name Theme modification name.
 * @param string $value theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $old_value = isset($mods[$name]) ? $mods[$name] : false;
    /**
     * Filter the theme mod value on save.
     *
     * 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 3.9.0
     *
     * @param string $value     The new value of the theme mod.
     * @param string $old_value The current value of the theme mod.
     */
    $mods[$name] = apply_filters("pre_set_theme_mod_{$name}", $value, $old_value);
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}

WordPress Version: 3.7

/**
 * Update theme modification value for the current theme.
 *
 * @since 2.1.0
 *
 * @param string $name Theme modification name.
 * @param string $value theme modification value.
 */
function set_theme_mod($name, $value)
{
    $mods = get_theme_mods();
    $mods[$name] = $value;
    $theme = get_option('stylesheet');
    update_option("theme_mods_{$theme}", $mods);
}