PHPMatters Help You Better Hosting Your PHP-based Sites
How to Add a Twitter Tweet Button on Your Site for Better Content Sharing

How to Add a Twitter Tweet Button on Your Site for Better Content Sharing

Previously, we have already told you how to add Twitter Follow button on your website to achieve an easy following. This time, we’d like to continue our Twitter class showing you how to add a Twitter Tweet button.

Unlike the follow button that is used to increase the number of your Twitter followers, this one can make your website sharing an easy task. Generally, if people want to share your pages or articles, they need to log into their Twitter accounts and start tweeting with the page URL attached. With this button, however, people only need to make a click on it and then hit on the Tweet button, meaning that they can share your content with their own followers merely after two simple clicks.

share link

Get the Coding Stuff

In fact, the way for adding a Tweet button is almost the same as adding a follow button. Thus, the first thing you need to do is to get the code needed from this page. After getting into this development page and choose the first button type of “share a link”, you can see the options as the image showed in the following.

tweet button options

  • Share URL – Enter the URL of the website or page that you want other people to share around the world.
  • Text – Type the site name, post title, or a brief content summary corresponding to the URL. The text will be shown before the URL to tell people what the page is talking about.
  • Count – You can choose to show the count box or not based on your preference by checking the small box.
  • Twitter Account – You can enter your Twitter account next to the “Via” option, telling people that you are the original twitter who share the contents.
  • Recommended Account – You can also enter other two related Twitter accounts to recommend people to follow.
  • Hashtag – Enter the keyword of your shared page. The hashtag can help people find you easily.
  • Language – You can choose the language from the dropdown menu.

After finishing all of these options, you can see the button preview and the needed coding in the right-hand section. If you are satisfied with the button appearance, then simply copy the code and paste it to a safe file for the further utilization.

Modify the Button Appearance

As different user has the different habit, the appearance of this button can be modified. Due to the fact that you are using JavaScript to add the button to your website, you can start the modifications easily using the data attributes.

  • Size – You can render the button size between “medium” and “large”.
  • Count – You can choose not to showcase the count with the property of “none”. Also, you can display the count either vertically or horizontally using the property of “vertical” and “horizontal”.

Paste the Code to Website

The code can be pasted at anywhere you want, such as the theme, widget, or the content. However, if you want to promote the whole site, you’d better add the code to your widget that can be showed at any page of your site. We have already told you how to do this at the post on how to add Twitter Follow button. The process is simple, which can be done within minutes.