Monthly Archives: January 2011

Integrating WordPress with Twitter

Suppose I want to integrate my WordPress blog with Twitter or in other words I wish to tweet from my WordPress blog. I also want that my tweets on Twitter.com should appear as posts in my WordPress blog. For this purpose, I have chosen the Twitter Tools plugin by Crowd Favorite. You can have more information about this plugin from its site, http://crowdfavorite.com/wordpress/plugins/twitter-tools. On installing and activating this plugin, a message appears at the top of the Plugins page: Please update your Twitter Tools settings with a link to set the Twitter Tools options. Also in the Settings menu, one menu option is automatically added, Twitter Tools.  We can choose either way to set the Twitter Tools options. The Twitter Tools Options page appears as shown in below given figure. The page asks us to register our blog as an application on Twitter.com. The page also guides us about the options that we need to select in the registration page.

Twitter Tools Options page

The four blank boxes, Twitter Consumer Key, Twitter Consumer Secret, Access Token and Access Token Secret have to be filled with their respective values auto generated on registering our blog at Twitter.com. These values are required to make our plugin functional. So, let us proceed with the procedure of registering our blog by selecting the link, Twitter’s app registration page. This link navigates us to the Twitter Developer’s page where we are prompted to Sign In using our Twitter username and password. On entering a valid user name and password, we get a page to register our application. While registering our application, we can take the help of information displayed in above figure meant to guide us. Let us register our blog by entering the information as shown in below given figure.

Page to register our blog as an application at Twitter.com

On selecting the Register application button, we get a page displaying Twitter API Terms of Service. After reading the terms, we need to accept them to use the plugin. We get a page informing that our application has been registered successfully. The page also displays API key, Consumer Key and Consumer secret key. The page also displays a button, My Access Token that we select to get the Access Token and Access Token Secret values. We can copy and paste these auto-generated values in the respective boxes of Twitter Tools Options page (refer the first figure). After entering these values, we select the Connect to Twitter button to connect our WordPress blog to the Twitter.

The Twitter Tools Options displays a message confirming that our blog is connected to the Twitter. The Twitter Tools Options page displays a few more options to configure our plugin in detail. These options help us to:

  • determine whether to create a tweet when we post in our blog,
  • set the Tweet prefix for the new blog posts,
  • determine whether to create a blog post from our tweets,
  • select the category to assign to the tweet posts,
  • define tags for the tweet posts,
  • select an author for the tweet posts,
  • define the number of tweets to be shown in the sidebars, etc.

After choosing the desired options, we save them by selecting the Update Twitter Tools Options button. That is it; the Twitter Tools plugin is configured and fully functional. Now, if I tweet on Twitter.com (refer below given figure (a)), the tweet will appear as a blog post in our blog as shown in below given figure (b).

(a) Tweet at Twitter.com (b) Tweet appears in the form of post in the blog

Twitter Tools plugin adds an extra menu option, Tweet in Posts menu that can be used to create tweets when we post in our blog. On selecting the Tweet option from the Posts menu we get a Write Tweet page (below figure (a)) where we can write the message. The message not only appears as a blog post on our blog but also appears as a tweet on Twitter.com (below figure (b)).

(a) Writing Tweet in our blog (b) Tweet written in the blog appears in Twitter.com

To display our latest tweets and to tweet from our sidebars, we can make use of the Twitter Tools widget that is automatically added to the Widgets page on successful installation of the Twitter Tools plugin. So, let us open the Widgets page by selecting the Appearance->Widgets option from the main navigation menu and drag the Twitter Tools widget from the Available Widgets list and drop it on either of the sidebars. Let us set the title of the widget to My Tweets (below figure (a)) and select the Save button to save the widget. In our blog, we find that our latest tweets appear along with a textbox allowing us to tweet from our blog’s sidebars as shown in below given figure (b).

Note: The textbox to tweet appears in the sidebars only when the administrator is logged in.

(a) Options of Twitter Tools Widget (b) Latest tweets and textbox to tweet in the sidebars

For more information, refer my book, Blogging with WordPress 3 for Beginners available at Amazon.

Installing WordPress Locally

WordPress requires a web server with PHP support, a URL rewriting module and an instance of MySQL. The URL rewriting module that understands .htaccess directives is required for the purpose of getting search engine friendly URLs. WordPress generates search engine friendly URLs also called permalinks through URL rewriting modules. Hence, the servers such as Apache or IIS7 providing URL rewriting are popularly used for installing WordPress.

The installation process is quite simple. We need a server software (MAMP, XAMP or WAMP) and a WordPress package (download it from wordpress.org) and follow the below given steps:

  • Install a local server (Mac: MAMP, PC:XAMPP or WAMP). Figure 1 displays XAMPP control panel that automatically appears on successful installation of XAMPP. We can see that Apache and MySQL both are in running mode.

Note: Mac OS X comes with an Apache web server (with PHP and URL rewriting).

Figure 1. XAMPP Control Panel

  • Next, we have to create a new database. Select the Admin button besides MySQL from XAMPP control panel to open phpMyAdmin. In the Create new database textbox, enter the name of the new database as wordpress_local (any) followed by selecting the Create button as shown in Figure 2. After creating the database, the next thing we have to do is to set the password of the root. We will be using the user, root (that has all the privileges by default) to access the newly created database. By default, when we install XAMPP, there is no password set for the root. To set the password of the root, select Privileges link from the top (Figure 2). We get a User overview page displaying the list of default users. Select the Edit privileges icon for the root on localhost. We get a box to specify password for the root. Lets enter the password for the root as mce (any text)

Note: The phpMyAdmin is a free software tool written in PHP that manages the administration of MySQL over the World Wide Web. It helps us perform variety of database manipulation tasks quite easily.

Figure 2. Creating MySQL database through phpMyAdmin

  • Extract the downloaded WordPress package in a folder say blog (or any other name). Copy the blog folder containing the WordPress files into the root directory of our server, i.e., in its htdocs folder.
  • In the blog folder, we will see that besides other files, WordPress package provides a template configuration file also. The configuration file is named wp-config-sample.php. First, we have to rename the wp-config-sample.php file to wp-config.php and then update it to specify the information (db_name, user, password, host) of the newly created database, wordpress_local in it. Hence, open the wp-config.php file and search for the following three lines:

define(‘DB_NAME’, ‘database_name_here’);

define(‘DB_USER’, ‘username_here’);

define(‘DB_PASSWORD’, ‘password_here’);

and modify them to appear as shown below:

define(‘DB_NAME’, ‘wordpress_local’);

define(‘DB_USER’, ‘root’);

define(‘DB_PASSWORD’, ‘mce’);

where wordpress_local is the database we just created through phpMyAdmin, root is the default user with all privileges and mce is the password that we have set for the root through phpMyAdmin. Save the wp-config.php file after making these changes.

  • Open the browser and point it at the URL, http://localhost/blog/wp-admin/install.php to begin the WordPress installation process. The word, blog appears in the URL because we have renamed the WordPress package directory to blog before copying it on our web server’s root directory. On doing this, we get a Welcome page asking information for the blog that we want to create. The page represents the beginning of the WordPress’s five minute installation process. We enter the title of the blog, name, password and email address of the administrator in the respective textboxes as shown in Figure 3. Also, select the checkbox, Allow my site to appear in search engines like Google and Technorati if we are making a blog that is open for public and finally select the Install WordPress button.

Figure 3. Page showing WordPress’s five minute installation process

We get a Success message (Figure 4) declaring that WordPress is successfully installed on our local server. If we enter administrator’s name and password and select the Log In button, the Dashboard of our blog opens up to administer our blog. Later in this chapter, we will understand Dashboard and its role in administering a blog.

Figure 4.  Page confirming successful installation of WordPress

To visit our newly created blog, open the browser and point it at the address, http://localhost/blog/. Our blog is displayed with a default post, Hello world! provided by WordPress as shown in Figure 5.

Figure 5. Blog displaying the default post Hello world!

In order to open the login page again, point the browser to the following address, http://localhost/blog/wp-login.php

For more information, refer my book, Blogging with WordPress 3 for Beginners available at Amazon.

WordPress book for Beginners

Blogging with WordPress 3 for Beginners : A Practical Guide to build and maintain your own blog

If you’ve ever wanted to learn how to build and maintain your own blog, Blogging with WordPress 3 for Beginners is for you! This book will lead you through all the building blocks necessary for a fully functional blog in WordPress platform.


The book covers :
• Different ways of installing WordPress
• Creating and managing blog contents through Posts and Pages
• Managing Media, Links and Comments
• Managing Themes, Custom Menus and Widgets.
• Managing user accounts, roles and setting profiles
• Extending features of blog through plugins.
• Using Tools and Settings
• Using Press This tool to grab web pages found on the net
• Importing contents from different blogging platforms
• Exporting the WordPress blog contents
• Submitting posts via email and through desktop client
• Generating search engine friendly URLs
• Translating blog contents into different languages
• Integrating blog with Facebook and Twitter
• Taking Online Backup
• Generating XML Sitemaps and displaying advertisement for revenue

Available at Amazon