I'm trying to get a list of all theme mods / options currently registered. The normal way you can do it is to be inside the customizer, then $wp_customize->settings()
.
This will return a k,v
pair of all the currenty registered theme mods that can, say, be saved.
If I inspect the global wp_customize
outside the customizer itself, it's null, as expected.
Is there a workaround for this?
I'm trying to get a list of all theme mods / options currently registered. The normal way you can do it is to be inside the customizer, then $wp_customize->settings()
.
This will return a k,v
pair of all the currenty registered theme mods that can, say, be saved.
If I inspect the global wp_customize
outside the customizer itself, it's null, as expected.
Is there a workaround for this?
Share Improve this question asked Oct 30, 2019 at 13:59 Daniel SmithDaniel Smith 617 bronze badges1 Answer
Reset to default 0You don't need to fake being in the customizer, just grab the theme mods directly via get_theme_mods
. Afterall they're just theme specific options.
Something like this would print out all the theme mods in a definition list:
function tomjn_print_theme_mods() {
$mods = get_theme_mods();
if ( empty( $mods ) {
return;
}
echo '<dl>';
foreach ( $mods as $k => $v ) {
echo '<dt>'.esc_html( $k ).'</dt>';
echo '<dd>'.esc_html( $v ).'</dd>';
}
echo. '</dl>';
}
https://codex.wordpress/Function_Reference/get_theme_mods
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745043239a4607937.html
评论列表(0条)