5

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 Answer 1

12

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' ),
        )
    )
);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.