Hi there,
I have followed the instruction in this post: https://theme.co/apex/forums/topic/how-to-create-custom-author-archive-page-and-link-to-it/ to add a link to the author archive in the shortcode.
I’ve also added a function to automatically add the author shortcode to the bottom of each post.
The author name is not linking. Please see here for example: https://dev.helenscloset.ca/2019/06/25/ashton-top-tester-roundup/
The full functions are here:
// Add link to Author Shortcode
// =============================================================================
function x_shortcode_author_v2( $atts ) {
extract( shortcode_atts( array(
'id' => '',
'class' => '',
'style' => '',
'title' => '',
'author_id' => ''
), $atts, 'x_author' ) );
$id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : '';
$class = ( $class != '' ) ? 'x-author-box cf ' . esc_attr( $class ) : 'x-author-box cf';
$style = ( $style != '' ) ? 'style="' . $style . '"' : '';
$title = ( $title != '' ) ? $title : __( 'About the Author', csl18n() );
$author_id = ( $author_id != '' ) ? $author_id : get_the_author_meta( 'ID' );
$description = get_the_author_meta( 'description', $author_id );
$display_name = get_the_author_meta( 'display_name', $author_id );
$facebook = get_the_author_meta( 'facebook', $author_id );
$twitter = get_the_author_meta( 'twitter', $author_id );
$googleplus = get_the_author_meta( 'googleplus', $author_id );
$author_link = get_author_posts_url(get_the_author_meta( 'ID' ));
$facebook_output = ( $facebook ) ? "<a href=\"{$facebook}\" class=\"x-author-social\" title=\"Visit the Facebook Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i> Facebook</a>" : '';
$twitter_output = ( $twitter ) ? "<a href=\"{$twitter}\" class=\"x-author-social\" title=\"Visit the Twitter Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i> Twitter</a>" : '';
$googleplus_output = ( $googleplus ) ? "<a href=\"{$googleplus}\" class=\"x-author-social\" title=\"Visit the Google+ Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i> Google+</a>" : '';
$output = "<div {$id} class=\"{$class}\" {$style}>"
. "<h6 class=\"h-about-the-author\">{$title}</h6>"
. get_avatar( $author_id, 180 )
. '<div class="x-author-info">'
. "<h4 class=\"h-author mtn\"><a href=\"{$author_link}\">{$display_name}</a></h4>"
. $facebook_output
. $twitter_output
. $googleplus_output
. "<p class=\"p-author mbn\">{$description}</p>"
. '</div>'
. '</div>';
return $output;
}
add_filter('init', 'custom_author');
function custom_author() {
remove_shortcode( 'x_author' );
add_shortcode( 'x_author', 'x_shortcode_author_v2' );
}
// =============================================================================
// Add author box to bottom of each post
// =============================================================================
function the_content_with_author_box( $content ){
if( is_single() || is_page() ){
$content .= do_shortcode( '[author title="About author"]' );
}
return $content;
}
add_filter( 'the_content', 'the_content_with_author_box', 11, 1 );
// =============================================================================