sonia maklouf sonia maklouf - 6 months ago 42
PHP Question

undo escape of get_theme_mod function in wordpress

I'm trying to echo

variable in PHP. This variable are HTML tag but it's seen like text in the browser.

<footer class="site-footer" role="contentinfo">
<?php $preloader_val = get_theme_mod( 'my_s', 'homepage' );
$loaders_val = get_theme_mod( 'my_ser', '<div class="loading-overlay"><div class="loader-inner ball-zig-zag"><div></div><div></div></div></div>' );
if ( $preloader_val == "page") {
echo '<section id="loader">'.$loaders_val.'</section>';
}elseif ($preloader_val == "homepage" && is_front_page()){
echo "<section id='loaders'>$loaders_val</section>";
} elseif ($preloader_val == "none") {


Which give something like this in the browser:
click here

My $loaders_val is being escaped and i found no additional parameter to passing to get_theme_mod function for output html

Is there a way to output html with get_theme_mod ?


You can try to hook your theme modification like this:

function my_htmlspecialchars_decode($value) {
    return htmlspecialchars_decode($value);
add_filter('theme_mod_my_ser', 'my_htmlspecialchars_decode');