WordPress filters

Use filters to modify data sent to the BeyondWords for WordPress plugin.

This guide explains how to use filters to modify the data sent to the 'BeyondWords – Text-to-Speech' WordPress plugin.

📘

BeyondWords is the new name for SpeechKit

BeyondWords was formerly known as SpeechKit. Please note that the old brand name is featured in some of these filters. Learn about filters on WordPress >

beyondwords_post_metadata: Filters the post metadata sent to the BeyondWords API.

Available since v3.3.0.


$metadata object

The post metadata. Defaults to the taxonomies and terms assigned to the post.


$post_id int

The post ID.



function beyondwords_post_metadata( $metadata, $post_id ) {
    // Send a custom field named "my_custom_field" to the BeyondWords API as "my_custom_key"
    $metadata->my_custom_key = get_post_meta($post_id, 'my_custom_field', true);

    return $metadata;
}
add_filter( 'beyondwords_post_metadata', 'beyondwords_post_metadata', 10, 2 );


speechkit_post_player_enabled: Override whether the Player is enabled/disabled for a specific post.

$enabled boolean

Is the Player enabled?


$post_id int

The post ID.


php

function speechkit_post_player_enabled( $enabled, $post_id ) {
    // Disable the Small Player for a specific Post ID
    if ( $post_id === 42 ) {
      $enabled = false;
    }

    return $enabled;
}
add_filter( 'speechkit_post_player_enabled', 'speechkit_post_player_enabled', 10, 2 );

speechkit_content: Override the content used to generate audio.

$content string

Content of the current post.


$post_id int

The post ID.


php

function speechkit_content( $content, $post_id ) {
    // Override the content which is sent to the SpeechKit API
    $content = 'Content of the current post';

    // Or use $post_id to get content from plugins such as Advanced Custom Fields.

    return $content;
}
add_filter( 'speechkit_content', 'speechkit_content', 10, 2 );

speechkit_js_player_params: Filters the BeyondWords JavaScript SDK parameters.

$params array

function speechkit_js_player_params( $params ) {
  // Use the Medium Player (by specifying the "manual" embed method)
  $params['playerType'] = 'manual';

  return $params;
}
add_filter( 'speechkit_js_player_params', 'speechkit_js_player_params', 10 );

speechkit_amp_player_html: Filters the HTML of the BeyondWords AMP audio player.

$html string

The HTML for the audio player.


$post_id int

WordPress Post ID.


$project_id int

BeyondWords Project ID.


$podcast_id int

BeyondWords Podcast ID.

function speechkit_amp_player_html( $html, $post_id, $project_id, $podcast_id ) {
    // Add a custom wrapper to the default AMP audio player HTML.
    $html = '<div class="amp-player-wrapper">' . $html . '</div>';

    return $html;
}
add_filter( 'speechkit_amp_player_html', 'speechkit_amp_player_html', 10, 4 );

speechkit_js_player_html: Filters the HTML of the BeyondWords JS audio player.

$html string

The HTML for the audio player. The audio player JavaScript may fail to locate the target element if you remove or replace the default contents of this parameter.


$post_id int

WordPress Post ID.


$project_id int

BeyondWords Project ID.


$podcast_id int

BeyondWords Podcast ID.

function speechkit_js_player_html( $html, $post_id, $project_id, $podcast_id ) {
    // Add a custom wrapper to the default JavaScript audio player HTML.
    $html = '<div class="js-player-wrapper">' . $html . '</div>';

    return $html;
}
add_filter( 'speechkit_js_player_html', 'speechkit_js_player_html', 10, 4 );

speechkit_post_statuses: Filters the post statuses that BeyondWords considers for audio processing.

When a post is saved with any other post status, data will not be sent to the BeyondWords API.

The default values are publish, future, and private.

Available since v3.2.0.


$statuses string[]

The post statuses that we consider for audio processing.

function speechkit_post_statuses( $statuses ) {
    // Add a custom status (which may be provided by another plugin)
    $statuses[] = 'your_custom_status';

    return $statuses;
}
add_filter( 'speechkit_post_statuses', 'speechkit_post_statuses' );

speechkit_post_types: Filters the post types supported by BeyondWords.

This defaults to all registered post types with custom-fields in their supports array.

If any of the supplied post types do not support custom fields then they will be removed from the array.

Available since v3.2.0.


$post_types string[]

An array of post type names.

function speechkit_post_types( $post_types ) {
    // $post_types contains the currently-supported post types

    // Only support 'posts'
    return ['posts'];
}
add_filter( 'speechkit_post_types', 'speechkit_post_types' );


Did this page help you?