How to Display Twitter Feed
To help you display your Twitter feed on your website, Twitter's profile widget creates the code for you. The widget allows you to customize the Twitter feed's appearance on your Web pages, such as changing how many tweets appear, its colors and size. To include the feed on multiple pages efficiently, save the widget in a PHP file and include it on each page. This way, when you customize the widget, you need only modify one file and the changes will apply to all instances of the Twitter feed across your site.
Instructions
-
-
1
Open a Web browser and visit the Twitter profile widget page. Type your Twitter user name into the text box. Click "Finish & Grab Code." Copy the code in the text box that appears.
-
2
Open a new text file. Name it "side.php" and save it. Type the following:
<?php
function twitter() {
?>
This code opens a PHP tag and declares a function called "twitter" that takes zero parameters. It then closes the PHP tag.
-
-
3
Paste the code you copied from the Twitter profile widget page. This is HTML code so you don't want to paste it within a PHP tag.
-
4
Type the following to open another PHP tag and to close the "twitter" function:
<?php
}
?>
-
5
Save the PHP file and upload it to your Web server.
-
6
Open one of your HTML files. Insert the cursor where you want to display the Twitter feed.
-
7
Type the following:
<?php
include('side.php');
twitter();
?>
This opens a PHP tag and includes the "side.php" file. It calls the "twitter" function, then closes the PHP tag. Make sure the path you supply as a parameter in the "include" function goes to where you uploaded the PHP file on your server.
-
8
Save the HTML file and upload it to your Web server. Display your Twitter feed on any additional HTML pages by including the "side.php" file and calling the "twitter" function.
-
1
Tips & Warnings
If you do not want to display the Twitter feed on multiple pages, paste the code you copy from the Twitter profile widget page directly into one HTML file. You do not need to use PHP.