Last active
May 5, 2020 15:01
-
-
Save ajskelton/b8cae9638bc33ab3440ce61b39f256d5 to your computer and use it in GitHub Desktop.
Add a URL field to the WordPress Customizer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$wp_customize->add_setting( 'themeslug_url_setting_id', array( | |
'capability' => 'edit_theme_options', | |
'sanitize_callback' => 'themeslug_sanitize_url', | |
) ); | |
$wp_customize->add_control( 'themeslug_url_setting_id', array( | |
'type' => 'url', | |
'section' => 'custom_section', // Add a default or your own section | |
'label' => __( 'Custom URL' ), | |
'description' => __( 'This is a custom url input.' ), | |
'input_attrs' => array( | |
'placeholder' => __( 'http://www.google.com' ), | |
), | |
) ); | |
function themeslug_sanitize_url( $url ) { | |
return esc_url_raw( $url ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does that make those suggestions for posts and existing pages?