8 Great Twitter ,Facebook, Googleplus Tricks for WordPress

Home/Wordpress tricks/8 Great Twitter ,Facebook, Googleplus Tricks for WordPress

8 Great Twitter ,Facebook, Googleplus Tricks for WordPress

1- Sainte-Thérèse Get User’s Tweets

You can get user tweets if the twitter profile is a public profile. The code below gives you the feed which can be styled in any way you like.

function getTweets($user) {

    $page= file_get_contents("http://twitter.com/{$user}");
    $from = strpos($page, "<ol id="timeline" class="statuses">"); $to = strpos($page, "</ol>");
    $length = $to - $from;
    $page =substr($page, $from, $length);
    echo $page;

getTweets('axactsoft'); //replace axactsoft with your twitter username

2- Eden Disable Admin bar

Here is a trick to disable the wordpress admin bar, use this code in functions.php

add_filter('show_admin_bar', '__return_false');

3- cenforce 50 mg Add Google plus one button

Google plus one buttons allows user to give a rating to your blog, posts or pages. It easy to display the plus one button wherever you want. Just follow the code and instructions below.

<!-- Place this tag in your head or just before your close body tag -->

<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>

<!-- Place this tag where you want the +1 button to render -->


4- Get Tweet Count.

Sometimes you would not like a long list of tweets shown to user. You only want to show the count of twitter followers to influence them to follow you (or not follow you lol) on twitter. You can write a simple snippet or plugin for that.First create paste the the code below in your functions.php

function update_twitter_count() {
$name = 'emerald_gal';
$url = 'http://api.twitter.com/1/users/show.xml?screen_name='. $name;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
$xml = new SimpleXMLElement($data);
$count = $xml->followers_count;
$count = (float) $count;
$count = number_format($count);
update_option('twitter_followers', $count);

function twitter_count() {
	echo get_option('tb_twitter_followers');

if (!wp_next_scheduled('your_hourly_hook')) {
	wp_schedule_event(time(), 'hourly', 'your_hourly_hook');
add_action('your_hourly_hook', 'update_twitter_count');

Now to display the count anywhere use

<a href="http://twitter.com/emerald_gal"><?php twitter_count(); ?> Followers</a> //replace emerald_gal with your twitter username

5- Add Social media Twitter and Facebook Buttons To postsSocial Media

sharing for your posts is must these days. It makes your blog engaging, interesting and popular. People would recommend your posts on their facebook and twitter account by just a single click. The code below will add twitter and facebook buttons at the end of your blog posts.

function share_this($content){
    if(!is_feed() && !is_home()) {
        $content .= '<div class="share-this">
                    <a href="http://twitter.com/share"
                    <script type="text/javascript"
                    <div class="facebook-share-button">
scrolling="no" frameborder="0" style="border:none;
overflow:hidden; width:200px; height:21px;"
    return $content;
add_action('the_content', 'share_this');

7- Facebook Share button Shortcode

If you want to show the fb share button bu using a shortcode on your website, use this code in functions.php

function facebook_share3() {
    return '</pre>
<div class="fbshare"></div>
add_shortcode( 'facebook_share', 'facebook_share3' )

The shortcode available to you now can be used as

[facebook_share]Insert your text here[/facebook_share]

8-Display the number of tweets for each page or post

This is a great trick to tell users about the number of tweets for a particular post. For using this code make sure that the SimpleXML PHP extension is enabled.

First write this code in functions.php

function tweetCount($url) {
	$content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url);
	$element = new SimpleXmlElement($content);
	$tweets = $element->story->url_count;
 	echo $tweets." tweets!";

Then open up your theme’s single.php and use this to display the number of tweets for the post.


I found these snippets for social media very interesting, i hope you guys like it too. Do share your own if you any good snippets.

Yumna Tatheer

Yamna Tatheer is a WordPress Plugin developer and a Top-Rated Upwork professional. She is a part-time blogger from Lahore and loves to write about wordpress and freelance industry.

More Posts

Follow Me:

About the Author:

Yamna Tatheer is a Wordpress Plugin developer and a Top-Rated Upwork professional. She is a part-time blogger from Lahore and loves to write about wordpress and freelance industry.

Leave A Comment

WhatsApp chat