Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Add support for serial commas to Co-Authors Plus WordPress plugin.
- *
- * Filters coauthors_default_between_last to support serial commas, aka oxford commas, for 3 or more coauthors
- * ex: By Samantha Larson, Darby Minow Smith, and David Roberts
- * ex: By Samantha Larson and Darby Minow Smith
- */
- add_filter( 'coauthors_default_between_last', function( $between_last ) {
- // only be concerned with commas with ' and ' which is CAP's default value
- if ( ' and ' !== $between_last )
- return $between_last;
- // prefix a comma if there are more than two coauthors
- $coauthors = get_coauthors();
- if ( count( $coauthors ) > 2 )
- return ', and ';
- else
- return ' and ';
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement