Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Last active March 30, 2016 09:43
Show Gist options
  • Select an option

  • Save hsleonis/be4c8fb25310043dbe06b502e681253e to your computer and use it in GitHub Desktop.

Select an option

Save hsleonis/be4c8fb25310043dbe06b502e681253e to your computer and use it in GitHub Desktop.
WP Theme Modification API
<?php
/**
* Retrieves a modification setting for the current theme
* Get, set or remove values of theme customizer
*
* Functions
* get_theme_mod()
* get_theme_mods()
* set_theme_mod()
* remove_theme_mod()
* remove_theme_mods()
* Hooks [Here $name= Theme customizer settings ID]
* theme_mod_$name
*
* Reference: https://codex.wordpress.org/Theme_Modification_API
*/
$color = get_theme_mod( 'background_color', '#27AE60');
var_dump($color);
// #27AE60
$mods = get_theme_mods();
var_dump($mods);
// output example:
// array(2) { ["header_textcolor"]=> string(3) "333" ["header_image"]=> string(20) "random-default-image" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment