• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Twitter Hashtag, @ and Inline Tweet in WordPress

By Abhishek Ghosh August 26, 2014 5:37 pm Updated on June 1, 2017

Twitter Hashtag, @ and Inline Tweet in WordPress

Advertisement

We can integrate Twitter Hashtag, @ and Inline Tweet in WordPress in several ways. It matters how you want to use the features in your blog. With time, Twitter API has undergone a huge change, possibly you will want to read about hashtag system, Twitter Hashtag and Twitter Tricks and Cheat Sheet With New API guide to get used with Twitter specific stuffs. Plugins are there, we will definitely mention but one must know the existence of non-WordPress Plugin ways to integration. Essentially, using lot of plugins can make your database quite pathetic. There are some “paid Plugins” too, although buying such is not recommended as they will try to use some API to authenticate your item which might compromise your security.

 

Twitter Hashtag, @ and Inline Tweet in WordPress : Let Us Start With Easiest Example

 

We can not use @anywhere platform anymore, its old and retired. With PHP preg replace, we can simply do many works :

Vim
1
2
3
4
5
6
7
8
9
// Display Twitter @username links
function tweet($text) {
       $text = preg_replace('/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)@{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', "$1<a href=\"https://twitter.com/$2\" class=\"tweet-username\">@$2</a>$3 ", $text);
       $text = preg_replace('/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)#{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', "$1<a href=\"https://search.twitter.com/search?q=%23$2\" class=\"tweet-hashtag\">#$2</a>$3 ", $text);
       return $text;
}    
// Replace content and excerpt
add_filter('the_content', 'tweet', 9);
add_filter('the_excerpt', 'tweet', 9);

If we sanitize and add it on current Theme or Child Theme’s functions.php file, it will automatically link from text. But this is a hardcoded HTML link towards Twitter which you might not link. Possibly you know that, if @AbhishekCTRL is the username, we can reach it via hashtag too. These are same links :

Advertisement

---

Vim
1
2
3
https://twitter.com/#!/AbhishekCTRL
# equivalent to
https://twitter.com/AbhishekCTRL

Now, how we can create an inline Twitter Retweet Button, this is called Twitter Intent :

Vim
1
https://dev.twitter.com/docs/intents#retweet-intent

If you manually want to add a RT button, only inserting this after modification is enough :

Vim
1
2
3
<a href="https://twitter.com/intent/retweet?tweet_id=504205447910281216" class="retweet" style="display:inline-block;font-family:georgia,serif;font-size:12px;color:#000;text-decoration:none;padding:1px 5px;border:1px solid #ccc;border-radius:3px;background-color:#ddd;background:linear-gradient(to bottom, #f6f6f6, #ddd)">Retweet</a>
<style>.retweet:hover{opacity:0.9}</style>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wks");</script>

Here is the thing when I pasted in text mode in WordPress :

Retweet

Twitter-Hashtag-Inline-Tweet-in-WordPress

Indeed, I used only :

Vim
1
2
<a href="https://twitter.com/intent/retweet?tweet_id=504205447910281216" class="retweet" style="display:inline-block;font-family:georgia,serif;font-size:12px;color:#000;text-decoration:none;padding:1px 5px;border:1px solid #ccc;border-radius:3px;background-color:#ddd;background:linear-gradient(to bottom, #f6f6f6, #ddd)">Retweet</a>
<style>.retweet:hover{opacity:0.9}</style>

The Javascript is already loaded by the social sharing button. By the way, I grabbed the ID from here:

Vim
1
https://twitter.com/AbhishekCTRL/status/504205447910281216

Now, we can modify and exclude all css style – Retweet – click it, it will give you a nice Javascript popup! Quite easy code :

Vim
1
<a href="https://twitter.com/intent/retweet?tweet_id=504205447910281216" class="retweet">Retweet</a>

As the class="retweet" is there, it will work. Unless you are a fool, you will not use a Twitter Plugin for these simple usages. Oho, understood, you are not liking RT to the same stuff, you want a sentence to included to RT, right? You can retweet our Install WordPress with Nginx on Rackspace Cloud Server guide! Do it!. I retrieved it via an old post. Anyway, here is the thing :

Vim
1
<a href="https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fthecustomizewindows.com%2F2014%2F08%2Finstall-wordpress-nginx-rackspace-cloud-server%2F&text=Install%20WordPress%20with%20Nginx%20on%20Rackspace%20Cloud%20Server&tw_p=tweetbutton&url=http%3A%2F%2Fbit.ly%2F1sLQugH&via=AbhishekCTRL" class="retweet">You can retweet our Install WordPress with Nginx on Rackspace Cloud Server guide! Do it!</a>

Very easy. Look at this broken explanation :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# constant
<a href="https://twitter.com/intent/tweet?
# original referrer is the safe url of the post
original_referer=https%3A%2F%2Fthecustomizewindows.com%2F2014%2F08%2Finstall-wordpress-nginx-rackspace-cloud-server%2F
# &text is what will be shared
&text=Install%20WordPress%20with%20Nginx%20on%20Rackspace%20Cloud%20Server
# source is tweet button, its a hack
&tw_p=tweetbutton
# this is url shortener's url
&url=http%3A%2F%2Fbit.ly%2F1sLQugH
# via is me
&via=AbhishekCTRL"
# class is to force the javascript
class="retweet">
# my custom text
You can retweet our Install WordPress with Nginx on Rackspace Cloud Server guide! Do it!
# ended the hyperlink
</a>

The complex looking url is nothing but encoded url, you can read Percent-encoding and URL Encode/Decode to know more. You can retrieve an url in WordPress using the_permalink() function. That will make it automated. I will make it better in near future in fully handed way without using any plugin. I guess you have no complain now. Hashtag will get auto linked with that PHP script if you want. It is more easy – just a hyperlink, in case you want to manually do to prevent unwanted stuffs.

 

Twitter Hashtag, @ and Inline Tweet in WordPress : Middle With Javascript

 

In case you want auto link via Javascript. There is also method. First create a Twitter Application with your domain name – do not install those stuffs, only create the Twitter Application. You will get an API. Load this Javascript at header :

Vim
1
2
<a href="https://twitter.com/share" class="twitter-share-button" data-via="AbhishekCTRL" data-related="AbhishekCTRL" data-hashtags="AbhishekGhosh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wks');</script>

Unfortunately this automatic thing has limitations, despite it can work on all pages (no need to bother about the url). In action :

Tweet

Disadvantage is that, we can not reuse it for linking as many as we will love, plus if the person hits backspace, the session will get terminated.

 

Twitter Hashtag, @ and Inline Tweet in WordPress : End With Complicated Plugins

 

There are some plugins :

Vim
1
2
http://wordpress.org/plugins/evergreen-post-tweeter/
http://wordpress.org/plugins/twitter-tools/

 

Pure HTML, No Javascript, With Icon Font Twitter Hashtag, @ and Inline Tweet in WordPress

 

Here is a real working example :

Tweet this real working link .

We used this HTML :

Vim
1
<a class="twitter" href="http://twitter.com/home/?status=Twitter Hashtag, @ and Inline Tweet in WordPress https://thecustomizewindows.com/2014/08/integrate-twitter-hashtag-and-inline-tweet-in-wordpress/ by @AbhishekCTRL" target="_blank" title="Click to tweet this">Tweet this real working link <i class="icon-twitter"></i></a>

As icon-font is already loaded on this webpage with CSS for other Twitter icon, we need not to load anything more. You can perform search on our website with related keywords for any required helpful in-depth guide.

Tagged With include hashtags in wordpress excerpt , inline tweet , wordpress twitter hashtag

This Article Has Been Shared 327 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Twitter Hashtag, @ and Inline Tweet in WordPress

  • What is Ddos attack?

    Ddos means Distributed Denial of Service that can happen due to several reasons.

  • Apache HTTP Server Basics

    Apache HTTP Server is an open source and free product of the Apache Software Foundation and is the most widely used Web server on the Internet.

  • Top Cloud Computing Vendors

    Top Cloud Computing Vendors consists the name of the companies who has acceptable quality in the field of Cloud Computing as SaaS,IaaS or PaaS provider.

  • Cloud Computing is Becoming the Norm

    Cloud Computing is expanding more than it was calculated. As calculated,Cloud architectures will overtake in the next 3 years,over traditional IT architectures.

  • Command and Control Server and Technologies

    Command and Control Server are centralized servers which are able to send commands and a part of Botnet. Botnet is group of computers to run automated program.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (21K Followers)
  • Twitter (5.3k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Why Not to Use Your Host for Email Marketing March 5, 2021
  • What You Need to Know About the Microservices March 4, 2021
  • Fix Missing/Bad FileProvider for Freshchat (Android error code 354) March 3, 2021
  • Basics of Data Protection on the Internet March 2, 2021
  • What is Standard Software February 28, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "Twitter Hashtag, @ and Inline Tweet in WordPress," in The Customize Windows, August 26, 2014, March 6, 2021, https://thecustomizewindows.com/2014/08/integrate-twitter-hashtag-and-inline-tweet-in-wordpress/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2021 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy