Skip to content

Instantly share code, notes, and snippets.

@wpweb101
Last active August 4, 2018 05:08
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 wpweb101/197d210ae66378ff09ae9a60e705a876 to your computer and use it in GitHub Desktop.
Save wpweb101/197d210ae66378ff09ae9a60e705a876 to your computer and use it in GitHub Desktop.
Add follow author button in each type of post automatically
<?php
/**
* Add author follow button in each post
*/
function wpfmbp_add_author_follow_in_post( $content ) {
global $post;
if( isset( $post ) ) {
$author_id = $post->post_author;
// Add button on Top
$content = do_shortcode( '[wpw_follow_author_me author_id = "' . $author_id . '"]' ) . $content;
// Add button on Bottom
$content = $content . do_shortcode( '[wpw_follow_author_me author_id = "' . $author_id . '"]' );
}
// return content
return $content;
}
// add filter to add follow author button
add_filter( 'the_content', 'wpfmbp_add_author_follow_in_post' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment