WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Jun 02 2011

How to Add Google's +1 Buttons to Your Genesis Post Info

Google first rolled out +1 back on March 30th, 2011. Today Google announced that +1 can be incorporated on web pages!

So what is Google's +1?

Google writes:

The +1 button is shorthand for "this is pretty cool" or "you should check this out." Click +1 to publicly give something your stamp of approval. Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

And, since it is Google and most SEO people strive and aim towards Google optimization, then adding the +1 will be as important (if not more) than adding social bookmarking and the likes of Facebook and the follows or tweets of Twitter. Simply, as one writer states, "[It's Google's] attempt to become more social" around the web. Just as Google results are now saying who tweeted what, they will also be adding who +1'ed the search results! And while Google hasn't officially (or unofficially to my knowledge) stated that +1 will have an impact on search results or their algorithm I am going to bet that it will.

It will be interesting to watch how Google +1 grows. Facebook's LIKES are powerful social bookmarking tool of sorts because of its powerful social network connection. So if Google figures a way to have this drive search results, which I believe Google Buzz was probably supposed to do, then +1 could be just as powerful as Facebook's Like Us/This button.

Watch this video from Google about +1:

Caveats

Since Google is developing this, it will be driving Google services. So know your audience, for your visitors to be able to use the Google button, they’ll need both a Google Account and a Google Profile. Also, it is only available in US English.

As one Google watcher said:

Google will show +1 buttons next to all search results and ads, while encouraging other sites to include the buttons. All +1's are public and they're tied to Google Profiles. The goal is to use this data to personalize search results and ads by recommending sites +1'd by your friends. Google Social Search already does this, but there's no support for Facebook likes, so Google had to come up with a substitute.

And finally, also note that you can join this social experiment here, and here is what Google said about +1 appearing in searches, which currently appears to be browser specific??:

Please note, this experiment is browser-specific. From within each browser that you want to +1 from, you will need to repeat steps 1-2. Also, it may take a while before you see the button in search results, and it may occasionally disappear as we make improvements.

Customizing Google's +1 Code

However, to implement the Google share button, you don’t need a Google account. Google has provided a “configurator” for web site owners to quickly and easily grab several variations on the necessary Google +1 code.

However, here is their copy and paste code what the code is:
[html]<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>

<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>[/html]

Now can be further customized. They have four sizes:

  1. Small: 15px, size="small"
  2. Medium: 20px, size="medium"
  3. Standard: 24px, default
  4. Tall: 60px, size="tall"

To change the size insert size="small" (or whatever you choose) inside the first , such as . To remove the count just insert count="false". To add the specific URL, insert href="YOURURL".

To add the advanced options of (1) explicit parsing, include {parsetags: 'explicit'} and (2) javascript callbacks, include callback="CALLBACK".

Ok, so how do you add the +1 button to your Genesis site?

There's two methods:

  1. Copy and Paste the Google Copy and Paste Code into your Genesis Theme Settings > Header/Footer Scripts
  2. Use the following code snippets to further customize the +1's location in functions.php
  3. Download the full code, upload to your Child Themes lib folder, include require_once(CHILD_DIR.'/lib/google_plus_one.php'); in your functions.php file. Done!

Genesis Theme Settings

Go to Genesis > Theme Settings and scroll down to the bottom right. Copy and paste the following code into the header or footer box:
[html]<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>[/html]

Genesis Theme Settings for Google Plus 1
Click for a Larger Image

While Google encourages you to insert the code into the header (and again no one knows yet how Google will search for this code for SEO), it still is possible to place this in the footer too. As as the guys at DIY Themes determined:

The reason for this recommendation applies to load order and priority — if Google Plus One (+1) is having a bad day, your visitors shouldn’t be impacted. Light testing showed the +1 API may require from about 0.2 to 1.0 seconds to load fully when not cached.

Code Snippets for Genesis

In your functions.php, you will need to include Google's main javascript file.

Step 1: Call Google's JS
[php]<?php
function google_plus_one_integration() {
?>
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
<?php
}
//add_action('wp_head', 'google_plus_one_integration'); //insert code in header
add_action('genesis_after', 'google_plus_one_integration'); //insert code in footer before </body>
?>
[/php]

Step 2: Display where you want.
For Single Pages:
[php]<?php
//Add to Single pages only
function google_plus_one_output() {
if (is_single()) {
//note the use of the div tag for CSS purposes due to
//Google's funny method of applying a class to plusone
?>
<div class="my-plus-one">
<g:plusone size="medium"></g:plusone>
</div>
<?php }
}
//add_action('genesis_before_post_content', 'google_plus_one_output');
[/php]

For insertion into Genesis's post info:
[php]<?php
//add to post information
add_filter('genesis_post_info', 'my_post_info_filter');
function my_post_info_filter($post_info) {
$permalink = get_permalink();
if (!is_page()) {
$post_info = '[ post_date] By [ post_author_posts_link] [ post_comments] | Share: <g:plusone size="medium" href="'.$permalink.'"></g:plusone> [ post_edit]'; //remove spaces after initial [
//$post_info = 'Custom text'; //edit this to whatever you'd like.
}
return $post_info;
}
[/php]

BONUS: To add Twitter and Facebook with it in post info:
[php]<?php
//with Twitter and Facebook:
function my_post_info_filter($post_info) {
$permalink = get_permalink();
if (!is_page()) {
$post_info = '[ post_date] By [ post_author_posts_link] [ post_comments] | Share: <g:plusone size="medium" href="'.$permalink.'"></g:plusone><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><iframe class="fblikebtn" src="http://www.facebook.com/plugins/like.php?app_id=214741845223780&amp;href='.$permalink.'&amp;send=false&amp;layout=button_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe> [ post_edit]'; //remove spaces after initial [
//$post_info = 'Custom text'; //edit this to whatever you'd like.
}
return $post_info;
}
[/php]

Some CSS styling (please make it fit to your theme)
[html].fb_iframe_widget {float:right; margin-top: -25px;}
.twitter-share-button {float:right; width: 100px !important;}
.my-plus-one { float:right; }
#___plusone_0,#___plusone_1,#___plusone_2,#___plusone_3,#___plusone_4,#___plusone_5,#___plusone_6,#___plusone_7,#___plusone_8,#___plusone_9,#___plusone_10 {float:right; width:61px !important}
.fblikebtn {float:right; width:55px !important}[/html]

Note: The reason for the multiple CSS ids for the Google +1 (#___plusone_0, #___plusone_1, #___plusone_2, #___plusone_3, #___plusone_4, #___plusone_5, #___plusone_6, #___plusone_7, #___plusone_8, #___plusone_9, #___plusone_10) is because that's how Google codes the classes if there is more than one +1 (.___plusone -> 3 underscores + plusone). So if you have 11 posts on one page then you need your CSS to have this. Also note that it starts with zero (0).

<>h2>Download the code

For those of you who love simplicity and ease, just down load this zip file, unzip, upload the php file to your Genesis lib folder, and include the following code in functions.php.
[php]require_once(CHILD_DIR.'/lib/google_plus_one.php');[/php]

Download the file here: [download id="13"]

(The file inserts Google's Plus One in the post info.)

Written by Travis Smith · Categorized: WordPress

Jun 01 2011

Adding Capabilities to Facebook Tabs Custom Post Type in Facebook Tab Manager

Recently, I needed to make my Facebook Tabs closed to my client. However, the plugin didn't do this, so digging into it, there was one minor change that needed to be made regarding capabilities and capability_type. For a reference, view Justin Tadlock's post, Meta capabilities for custom post types.

Since I use the Members plugin to help me with role management, I only had to make one minor change in the custom post type registration code. Around line 270, fbtab.php registers the Facebook Tab custom post type. To add capabilities and the capability_type delete the create_fbtab_post_type function and use this function instead.

[php]<?php
function create_fbtab_post_type() {
register_post_type( 'fbtab',
array(
'labels' => array(
'name' => __( 'Facebook Tabs' ),
'add_new_item' => __( 'Add New Facebook Tab' ),
'edit_item' => __( 'Edit Facebook Tab' ),
'new_item' => __( 'Facebook Tabs' ),
'singular_name' => __( 'Facebook Tab' )
),
'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'fbtabs',
'capabilities' => array(
'publish_posts' => 'publish_fbtabs',
'edit_posts' => 'edit_fbtabs',
'edit_others_posts' => 'edit_others_fbtabs',
'delete_posts' => 'delete_fbtabs',
'delete_others_posts' => 'delete_others_fbtabs',
'read_private_posts' => 'read_private_fbtabs',
'edit_post' => 'edit_fbtabs',
'delete_post' => 'delete_fbtabs',
'read_post' => 'read_fbtabs',
),
'hierarchical' => true,
'has_archive' => true,
'menu_position' => 5,
'menu_icon' => plugins_url('/facebook.png',__FILE__),
'supports' => array('title','editor')
)
);

}
[/php]

Then I went into my Members plugin role management, created some capabilities based on the capabilities array. Then I locked out certain individuals. Wha la! For those who prefer the code to do this, please refer to Justin Tadlock's post, Meta capabilities for custom post types. It is "most excellent"! (I think I just dated myself!)

Written by Travis Smith · Categorized: WordPress

May 29 2011

How to Find Out What Shortcodes Are Active

I came across this neat little tidbit while trying to debug a shortcode to determine shortcode conflict, and I wanted to share with everyone. To find out what shortcodes are active on your site, use this simple code:
[php]global $shortcode_tags;
echo "<pre>"; print_r($shortcode_tags); echo "</pre>";
[/php]

Written by Travis Smith · Categorized: WordPress

May 05 2011

Testing Twitter Anywhere!

@wp_smith

Written by Travis Smith · Categorized: WordPress

Apr 25 2011

How to Add Facebook Tabs via WordPress

First, download and install the Facebook Tabs Manager Plugin by David Carr.

This plugin will get you started on how to begin creating Facebook plugins. John Hayden of Inbound Zombie created a YouTube video on basic usage of Facebook Tab Manager to customize your page.

So try it and get everything set up!


Facebook Tab Manager Shortcodes

[fblike like="0"] PROMO CONTENT[/fblike]
*Only shows to people who have NOT LIKED the page
[fblike like="1"] PROMO CONTENT[/fblike]
*Only shows to people who have LIKED the page
[fbtab query="posts_per_page=5"] or [fbtab query="category_name=clips"]
*Pull content from your blog
*Parameters like="1" like="0" format="excerpt" (or "headline" or "full")
[fbtab]<script>alert("silly example")</script>[/fbtab]
*Placeholder for inline JavaScript inserted in Visual Editor
*E.g., in visual editor,
[js]<script src="http://domain.com/wp-includes/js/jquery/jquery.js" type="text/javascript"><!--mce:0--></script>JQuery(domcuent).ready(function($){$('#eyechart').delay(2000).slideUp(600);});[/js]


Secure v. Regular Connection Issue with Facebook and Facebook Tab Manager

There is a known bug within Facebook. Simply click allow or yes.


IE Scrollbar Problems resolution

However, to make the tab fit within IE standards, I had to make a few adjustments. In my Facebook Tabs Post, I have the following selected:
*Set resize/autoresize (for tabs taller than 800 pixels)
*Hide post title, only show post content words / images

However, I still got a horizontal bar across the bottom (only in IE; how I loathe IE6-8). After trying various CSS hacks, I found adding this to the CSS worked:

[html]html {
overflow-x: hidden;
overflow-y: auto;
}
body {
width: 500px;
margin:0; padding:0; border:0;
overflow:hidden;
}[/html]

Written by Travis Smith · Categorized: Tutorials, WordPress

  • « Previous Page
  • 1
  • …
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 ďż˝ WP Smith on Genesis on Genesis Framework ďż˝ WordPress ďż˝ Log in