Skip to content

Instantly share code, notes, and snippets.

@rvc2
Created March 17, 2017 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvc2/4200d6041c7cda25c7ca125ec257e24d to your computer and use it in GitHub Desktop.
Save rvc2/4200d6041c7cda25c7ca125ec257e24d to your computer and use it in GitHub Desktop.
Add Author Info Box below WordPress posts using functions.php
function rvc_author_info_box( $content ) {
global $post;
// Detect if it is a single post with a post author
if ( is_single() && isset( $post->post_author ) ) {
// Get author's display name
$display_name = get_the_author_meta( 'display_name', $post->post_author );
// If display name is not available then use nickname as display name
if ( empty( $display_name ) )
$display_name = get_the_author_meta( 'nickname', $post->post_author );
$author_details = '<p class="author_info">The author, <i>' . $display_name . '</i>, is a member of <i>Southern Nevada Collaborative Divorce Professionals</i> which is an association of lawyers, mental health professionals, and financial professionals specializing in the collaborative divorce process. If you have questions about collaborative divorce , please contact ' . $display_name . '. Contact information can be found by clicking/tapping the author image or the "View Profile" link on this page. </p>';
// Pass all this info to post content
$content = $content . '<footer class="author_bio_section" >' . $author_details . '</footer>';
}
return $content;
}
// Add our function to the post content filter
add_action( 'the_content', 'rvc_author_info_box' );
// Allow HTML in author info section
remove_filter('pre_user_description', 'wp_filter_kses');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment