Newspack

The Newspack Theme adds some non-standard fields into the WordPress edit screens and presents the values in the theme template files. These custom fields are not be passed to our API by default, but you can send them to us using a WordPress filter.

Include Newspack custom fields in your audio content

If you want the Newspack Subtitle, Summary title and Summary body to be included in your audio content then you can use the beyondwords_content_params WordPress filter to send them to us.

<?php
    
function my_beyondwords_content_params( $params, $post_id ) {
    $subtitle = get_post_meta( $post_id, 'newspack_post_subtitle', true);
    $summary_title = get_post_meta( $post_id, 'newspack_article_summary_title', true);
    $summary = get_post_meta( $post_id, 'newspack_article_summary', true);
    
    $prepend = '';
    
    if ( $subtitle ) {
        $prepend .= '<p>' . esc_html( $subtitle ) . '</p>';
    }
    
    if ( $summary_title ) {
        $prepend .= '<p>' . esc_html( $summary_title ) . '</p>';
    }
    
    if ( $summary ) {
        $prepend .= '<p>' . esc_html( $summary ) . '</p>';
    }
    
    $params['body'] = $prepend . $params['body'];
    
    return $params;
}

add_filter( 'beyondwords_content_params', 'my_beyondwords_content_params', 10, 2 );

You can optionally include additional standard WordPress content that your theme may display, such as the author name and the article publish date, by integrating the code above with the Example 1 from our beyondwords_content_params WordPress filter documentation.

Last updated