Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress page template partial for Theme Foundry's Make theme modified to display Co-Authors and Guest Authors created with the Co-Authors Plus plugin.
<?php
/**
* @package Make
*/
// Modified for use with Co-Authors Plus - dan@newlocalmedia - 1-27-17 - Make 1.8.3
$author_key = 'layout-' . make_get_current_view() . '-post-author';
$author_option = make_get_thememod_value( $author_key );
?>
<?php if ( 'none' !== $author_option ) : ?>
<?php if ( function_exists( 'get_coauthors' ) ) { ?>
<?php $coauthors = get_coauthors(); ?>
<?php foreach ( $coauthors as $coauthor ) { ?>
<div class="entry-author">
<?php if ( 'avatar' === $author_option ) : ?>
<div class="entry-author-avatar">
<?php
printf(
'<a class="vcard" title="%1$s" href="%2$s">%3$s</a>',
esc_attr( $coauthor->display_name ),
esc_url( get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ) ),
coauthors_get_avatar( $coauthor, 65 )
); ?>
</div>
<?php endif; ?> <!-- End Co-Author Avatar .entry-author-avatar -->
<div class="entry-author-byline">
<?php
printf(
// Translators: the following text string (outside the author name variable '%s') is an attribution of a post author. e.g. 'by' Ernest Hemingway.
esc_html__('%s', 'make' ),
sprintf(
'<a class="vcard fn" href="%1$s">%2$s</a>',
esc_url( get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ) ),
esc_attr( $coauthor->display_name )
)
);
?>
</div>
<?php if ( isset( $coauthor->type ) && 'guest-author' == $coauthor->type ) { ?> <!-- Guest Author Bio -->
<?php if ( $coauthor->description ) : ?>
<div class="entry-author-bio">
<?php echo wpautop( Make()->sanitize()->sanitize_text( $coauthor->description ) ); ?>
</div>
<?php endif; ?>
<?php } else if ( $coauthor->user_description ) { ?> <!-- Co-Author Bio -->
<div class="entry-author-bio">
<?php echo wpautop( Make()->sanitize()->sanitize_text( $coauthor->user_description ) ); ?>
</div>
<?php } ?>
</div> <!-- End Author Box .entry-author -->
<?php } ?> <!-- End Co-Authors Loop -->
<?php } else { ?> <!-- If no Co-Authors do Single Author -->
<div class="entry-author">
<?php if ( 'avatar' === $author_option ) : ?>
<div class="entry-author-avatar">
<?php
printf(
'<a class="vcard" href="%1$s">%2$s</a>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
get_avatar( get_the_author_meta( 'ID' ) )
);
?>
</div>
<?php endif; ?>
<div class="entry-author-byline">
<?php
printf(
// Translators: the following text string (outside the author name variable '%s') is an attribution of a post author. e.g. 'by' Ernest Hemingway.
esc_html__( '%s', 'make' ),
sprintf(
'<a class="vcard fn" href="%1$s">%2$s</a>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author_meta( 'display_name' ) )
)
);
?>
</div>
<?php if ( is_singular() && $author_bio = get_the_author_meta( 'description' ) ) : ?>
<div class="entry-author-bio">
<?php echo wpautop( Make()->sanitize()->sanitize_text( $author_bio ) ); ?>
</div>
<?php endif; ?>
</div> <!-- End Author Bix .entry-author -->
<?php } ?> <!-- End Single Author Loop -->
<?php endif; ?> <!-- End Author Block -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.