• I’m trying to figure out if it’s possible to use the Customizer controls to create a “Designed By” dropdown menu, and have it echo out the name of the person/group with their name as a link in the footer. This is what I have in my customizer.php, but I’m not sure how to incorporate a URL:

    // Add "Designed by" notification in footer
      $wp_customize->add_setting(
        'powered_by',
        array(
          'default' => 'Group 1',
          'sanitize_callback' => 'sanitize_powered_by',
          'capability'        => 'edit_theme_options',
        )
      );
      $wp_customize->add_control(
        'powered_by', array(
        'section'  => 'footer_section',
        'label'    => __( 'Designed by' ),
        'type'     => 'select',
        'priority' => 8,
        'choices'  => array(
            'group1' => __( 'Group 1', 'ctotheme' ),
            'group2' => __( 'Group 2', 'ctotheme' ),
            'group3' => __( 'Group 3', 'ctotheme' ),
            'group4' => __( 'Group 4', 'ctotheme' )
          )
        )
      );

    And I have this in my footer.php:

    <?php
       if( get_theme_mod( 'hide_powered_by' ) == false) { ?>
         Designed by <a href="#" target="_blank"><?php echo get_theme_mod( 'powered_by' ); ?></a>.
       <?php } // end hide_powered_by if ?>

    Also, in the echo, instead of saying “Designed by Group 1”, it says “Designed by group1″… it’s using the label instead of the value associated with the label and I can’t figure out why. Any help? I’m a beginner to intermediate at PHP. I assume this would be a multidimensional array, but I’m not sure that can be used here.

Viewing 1 replies (of 1 total)
  • In your example, “group1”, “group2”, “group3”, etc. are the values that are stored in the theme option. That’s why you are getting “group1” when you retrieve that option.

    You have two options.

    1. Keep your code the way it is and translate the option to the appropriate label when you retrieve it.
    2. Change your code so that the value is the same as the label.
    3. 'choices'  => array(
          'Group 1' => __( 'Group 1', 'ctotheme' ),
          'Group 2' => __( 'Group 2', 'ctotheme' ),
          'Group 3' => __( 'Group 3', 'ctotheme' ),
          'Group 4' => __( 'Group 4', 'ctotheme' )
      )
Viewing 1 replies (of 1 total)
  • The topic ‘WP Customizer select with multiple values for "Designed By"?’ is closed to new replies.