• Home
  • Systems
  • Networking
  • WordPress
  • Web
  • Geekery

Analysis and Review

How to Add Google +1 To WordPress Blog

November 13, 2011 by Kurt Turner

If you’re using the Genesis Framework its easy to add this to your theme’s function.php – other themes use similar functions and hooks.

First add google plus one to the right of your post title.

[php]
add_action(‘genesis_post_title’, ‘google_plus_one’);
function google_plus_one()
{
if ( is_page() )
return; // don’t show google plus 1 on pages

?> <div class="plus_one"><g:plusone href="<?php the_permalink() ?>"></g:plusone></div>
<?php }
[/php]

The add some CSS to float it right

[php]
.plus_one {
float:right;
margin:-40px 0;
}
[/php]

Now add the google +1 javascript to your header so google can track the clicks.

[php]
add_action(‘genesis_post_title’, ‘google_plus_one_script’);
function google_plus_one_script()
{
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<?php }
[/php]

Filed Under: Wordpress

Latest and Greatest

Apache vs Nginx for WordPress

Certbot Lets Encrypt And WordPress MU Multi-Site

How To Find and Replace Multiple File in MS Word

How To Get Stretch Res on Windows 10 AMD Radeon For Game Play

This is the ASUS Chromebox we've been running for 2 years as our "brain" for our home grown digital display kiosk.

DIY Digital Signage Bulletin Board or Kiosk

© Copyright Analysis And Review · All Rights Reserved ·