[wp-trac] [WordPress Trac] #24844: get_theme_mods doesn't return the theme customizer preview's new values.

WordPress Trac noreply at wordpress.org
Sat Jan 17 16:24:51 UTC 2015


#24844: get_theme_mods doesn't return the theme customizer preview's new values.
--------------------------+------------------------------
 Reporter:  nessworthy    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Customize     |     Version:  3.5.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by jashwant):

 ''Same bug was bugging me.''

 I can reproduce the issue. Reason is the same, as explained by nessworthy.


 I've found a workaround though.

 Add your all customizer settings as an array, i.e. keep the `id` parameter
 of `add_setting` as keys of same array.

 e.g.


 {{{
 $wp_customize->add_setting('mytheme[header_color]' , array(
     'default' => '#000',
     'sanitize_callback' => 'sanitize_hex_color',
 ));

 $wp_customize->add_setting('mytheme[footer_color]' , array(
     'default' => '#ff0'
 ));
 }}}

 Now, you can get all customizer settings, in 1 go, with
 `get_theme_mod('mytheme')`. This will return an array, which you can use
 to get values of `header_color` and `footer_color` by supplying respective
 keys.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/24844#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list