I am wondering if it is possible to add placeholder text for WordPress Customizer input fields especially text and textarea fields.

I have added a input control by the code below. Can anyone tell me how I can add placeholder text to the input field?

$wp_customize->add_control('directorist_address', array(
            'label' => __('Address', 'directorist'),
            'section' => 'directorist_contact',
            'settings' => 'directorist_address',
            'description' => __('Enter your contact address. Eg. Abc Business Center, 123 Road, London, England'),
        )

);

The code above output an input field like below:

sample text input field in WordPress Customizer without placeholder

But I want to show some placeholder text inside the text input field.
Thanks

1
1

You can use the input_attrs argument to pass attributes to the input:

$wp_customize->add_control('directorist_address', array(
        'label' => __('Address', 'directorist'),
        'section' => 'directorist_contact',
        'settings' => 'directorist_address',
        'description' => __('Enter your contact address. Eg. Abc Business Center, 123 Road, London, England', 'directorist' ),
        'input_attrs' => array(
            'placeholder' => __( 'Placeholder goes here...', 'directorist' ),
        )
    )
);

Leave a Reply

Your email address will not be published. Required fields are marked *