Hi Alex,
Ahh I see, so the article authors won’t necessarily be the sponsored ones. Err no I’m afraid it can’t do that at the moment, it just assumes they’re the same. However, I’ve had a look and it’s not hard to add in. If you do decide to give it ago then you can add the code below to add an extra field at the bottom of the Content tab for each post. You can then add as many profiles as you like separated by a comma. It’s actually quite a good feature and I think we may add it in permanently in one of the upcoming releases.
All the best
/**
* Output the HTML for the custom authors field.
*
* @return void
*/
function wpna_custom_sponsored_authors() {
?>
<h3><?php esc_html_e( 'Custom Sponsored Authors', 'wp-native-articles' ); ?></h3>
<p class="description"><?php esc_html_e( 'Set custom sponsored authors. Should be links to Facebook profiles separated by commas.', 'wp-native-articles' ); ?></p>
<fieldset>
<div class="pure-control-group">
<label for="fbia_custom_authors"><?php esc_html_e( 'Custom Sponsored Authors', 'wp-native-articles' ); ?></label>
<input type="text" name="wpna_options[fbia_custom_authors]" id="fbia_custom_authors" class="" value="<?php echo esc_attr( get_post_meta( get_the_ID(), '_wpna_fbia_custom_authors', true ) ); ?>" />
</div>
</fieldset>
<?php
}
add_action( 'wpna_post_meta_box_facebook_custom_content_footer', 'wpna_custom_sponsored_authors', 10 );
/**
* Reigster fields that should be saved in the post meta.
*
* @param array $fields Fields that should be saved.
* @return array $fields
*/
function wpna_custom_post_meta_box_custom_authors( $fields ) {
$fields[] = 'fbia_custom_authors';
return $fields;
}
add_filter( 'wpna_post_meta_box_fields', 'wpna_custom_post_meta_box_custom_authors', 10, 1 );
add_filter( 'wpna_sanitize_post_meta_fbia_custom_authors', 'sanitize_text_field', 10, 1 );
function wpna_custom_sponsored_authors_output() {
$custom_authors = get_post_meta( get_the_ID(), '_wpna_fbia_custom_authors', true );
if ( ! empty( $custom_authors ) ) {
$authors = explode( ',', $custom_authors );
$authors = array_filter( $authors );
$authors = array_map( 'trim', $authors );
$output = '<ul class="op-sponsors">' . PHP_EOL;
foreach ( $authors as $author_url ) {
$output .= sprintf( '<li><a href="%s" rel="facebook"></a></li>', esc_url( $author_url ) ) . PHP_EOL;
}
$output .= '</ul>';
echo $output;
}
}
add_action( 'wpna_facebook_article_content_header', 'wpna_custom_sponsored_authors_output', 10 );