Using WordPress ‘remove_theme_mod()’ PHP function

The remove_theme_mod() WordPress PHP function removes a specific theme modification from the list of active theme modifications.

Usage

To use the remove_theme_mod() function, simply pass the theme modification name as a string:

remove_theme_mod('your_theme_mod_name');

Parameters

  • $name (string): The name of the theme modification to remove.

More information

See WordPress Developer Resources: remove_theme_mod()

Examples

In this example, we remove the custom logo from the active theme.

remove_theme_mod('custom_logo');

Remove a custom background image

In this example, we remove the custom background image from the active theme.

remove_theme_mod('background_image');

Remove a custom header image

In this example, we remove the custom header image from the active theme.

remove_theme_mod('header_image');

Remove custom colors

In this example, we remove custom colors (both primary and secondary) from the active theme.

remove_theme_mod('primary_color');
remove_theme_mod('secondary_color');

Remove custom font size

In this example, we remove the custom font size setting from the active theme.

remove_theme_mod('custom_font_size');