This tip can be applied to any other content you’d like to dynamically add to the end of your posts, but here’s how to add a Google +1 recommendation button under each post:
Open your theme’s functions.php file and paste the following code:
For many other social sharing buttons you can skip the part about adding a script into the head tag, but the Google +1 button requires this to function.//Google +1 Button below each postfunction add_google_plus_one($content) {if(!is_feed() && !is_home() && !is_page()) {$content .= '<g:plusone></g:plusone>';}return $content;}add_filter('the_content', 'add_google_plus_one');//add Google +1 Button script in headfunction add_google_plus_one_script() {if(!is_feed() && !is_home() && !is_page()) {echo '<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>';}}add_action('wp_head', 'add_google_plus_one_script');

0 comments:
Post a Comment