0

one of my clients have Branches. one located in new york another in los angeles and etc...

in the live site we print new york phone and address(from the customizer) as default.

what i need is to create drop down menu with all the Branches in the live site.

when the user will select "los angeles" for example, the phone number and the address will be updated based on customizer value (for each Branch i have field with phone and address).

in php i can simaple get the value by:

echo get_theme_mod( 'newyork_phone' );

the question is how can retrieve all the values i need from the customizer, based on user choose?

(function($){
    wp.customize("newyork_phone", function(value) {
    });
})(jQuery);

i tried to play with this code, but id did not get how can i get the "value" and print this in my theme?

in the theme customizer i am using this code:

$wp_customize->add_setting(
    'newyork_phone', 
    array(
    )
);

$wp_customize->add_control(
    'newyork_phone',
    array(
        'label' => __( 'Phone', 'test-admin' ),
        'section' => 'title_tagline', 
        'settings' => 'newyork_phone', 
        'priority'    => 15,
        'type' => 'text'
    )
 );

in the header.php i am using:

<select name="branches">
  <option value="newyork">new york</option>
  <option value="losangeles">los angeles</option>
</select>

then in jQuery i can get the value by:

$('select[name=branches]').val()

example: option one is "new york"

i want to get values:

newyork_phone

newyork_adress

etc...

option two is "los angeles"

losangeles_phone

losangeles_adress

and show the values in my theme.

  • Do you want to update the values in the customizer theme preview or in the live site once the customizer options have been saved? – cybmeta Mar 10 '15 at 8:20
  • Hi @cybmeta i want to update the values in the live site once the customizer options have been saved. – need-help Mar 10 '15 at 8:31
  • Are you defining the setting as theme_mod type or option type? – cybmeta Mar 10 '15 at 8:53
  • @cybmeta i have updated my question. – need-help Mar 10 '15 at 9:48
  • Hi @cybmeta can you help me with that? – need-help Mar 10 '15 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.