Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active January 4, 2019 01:46
Show Gist options
  • Save billerickson/a2781a96e623fd8e249ea2a72b0228d7 to your computer and use it in GitHub Desktop.
Save billerickson/a2781a96e623fd8e249ea2a72b0228d7 to your computer and use it in GitHub Desktop.
<?php
/**
* Multiple Authors in DPS
* @see https://displayposts.com/2019/01/04/display-multiple-authors-using-co-authors-plus/
*/
function be_multiple_authors_in_dps( $output = '', $original_atts = array() ) {
if( ! function_exists( 'coauthors' ) )
return $output;
$atts = shortcode_atts( array(
'coauthor_function' => 'coauthors',
'coauthor_between' => ', ',
'coauthor_between_last' => ' and ',
'coauthor_before' => 'by ',
'coauthor_after' => '',
), $original_atts, 'dps-coauthor-addon' );
$function = in_array( $atts['coauthor_function'], array( 'coauthors', 'coauthors_posts_links', 'coauthors_links' ) ) ? $atts['coauthor_function'] : 'coauthors';
$between = esc_html( $atts['coauthor_between'] );
$between_last = esc_html( $atts['coauthor_between_last'] );
$before = esc_html( $atts['coauthor_before'] );
$after = esc_html( $atts['coauthor_after'] );
$echo = false;
return ' <span class="author">' . call_user_func_array( $function, array( $between, $between_last, $before, $after, $echo ) ) . '</span>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment