1. Home
  2. Docs
  3. Text To Speech
  4. FAQ
  5. How to change button text?

How to change button text?

The Text to Speech (TTS) plugin is highly regarded for its flexibility, particularly in customizing button text to enhance the user interface on your WordPress site. This documentation explains two main techniques for changing button text: using shortcode attributes and using filters. Each method is accompanied by detailed examples to help you implement the changes easily.

Shortcode Attribute Method

The Text to Speech (TTS) plugin offers a straightforward way to change button text using shortcode attributes. These attributes allow you to define specific text for different button states. Here’s an example of how you can use shortcode attributes to customize button text:

In this example, you can see that each button state, such as “Listen,” “Pause,” “Resume,” and so on, can be customized to display your preferred text. Using shortcode attributes is a convenient and quick way to adjust button text to match your website’s style and branding.

Filter Method

The Text to Speech (TTS) plugin takes customization a step further by offering a filter that allows you to modify button text programmatically. While shortcode attributes are handy, filters provide greater flexibility and control. Here’s a step-by-step guide to using filters for customizing button text:

  1. Install the “Code Snippets” Plugin: To leverage filters, you’ll need to install the Code Snippets plugin. This plugin allows you to add custom code snippets to your WordPress site.
  2. Create a New Snippet: After installing the Code Snippets plugin, navigate to “Snippets” and select “Add New” to create a new snippet.
  3. Add the Filter Code: Copy and paste the following code block into your snippet:
add_filter( 'tta__button_text_arr', 'tta__button_text_arr_callback' );
function tta__button_text_arr_callback( $button_text_arr ) {
    // Customize button text here
    $button_text_arr['listen_text'] = 'Listen';
    $button_text_arr['pause_text'] = 'Pause';
    $button_text_arr['resume_text'] = 'Resume';
    $button_text_arr['replay_text'] = 'Replay';
    $button_text_arr['start_text'] = 'Start';
    $button_text_arr['stop_text'] = 'Stop';

    return $button_text_arr;
  1. Save and Activate: Save the snippet and activate it.

With this filter in place, you can modify button text programmatically by changing the text values within the callback function. This approach is particularly useful when you need to dynamically adjust button text based on specific conditions or requirements.

Whether you prefer the simplicity of shortcode attributes or the fine-grained control of filters, the Text to Speech (TTS) plugin provides you with the tools to create a tailored user experience on your WordPress site. Customizing button text is just one of the ways you can enhance your website’s accessibility and engagement.

How can we help?