Saturday, July 24, 2010

Twitter Tip: Add a ‘Tweet This’ Link to your Blog on WordPress or Blogger

Twitter can be a great source of traffic for your blog.
To give you an example, my article on bookmarklets was on
the delicious popular section for more than a day yet Twitter
sent in more visitors than delicious thanks to all the tweets.

Now if you want to make it easy for your site visitors to share
links of your blog articles on Twitter, follow the instructions
below – you don’t need any plug-ins and the post URLs are automatically
shortened in the tweet via bit.ly (a good alternative to tinyurl
that also provides live traffic statistics).

Add Tweet This to your WordPress Theme

Step 1: Open the header.php file of WordPress and insert the following lines
just before the closing tag.



Step 2: Open the single.php file and insert the following line just below
the_content() function.


Reading: Tweet This: Send Page to Twitter
There’s a similar service called TwitThis which is again easy to setup but it
requires the Twitter password so some of your readers may not feel very
comfortable doing that.

Add Twitter to Blogger Template

Go to your Blog Layout -> Edit HTML and click the box that says
"Expand widget templates".

Take a backup of your Blogger template. Now search for the class "post-footer"
in the Blogger XML template and copy-paste the following snippet somewhere near
that class.


Wednesday, July 7, 2010

Display a different image for each day of the week

Description

This PHP script will get the day of the week from the server
date and then display an image (jpg or gif) to match.

The code


/**
 * Change the name of the image folder
 *
 * Images must be named Monday.gif, Tuesday.gif etc
 */

// Change to the location of the folder containing the
 images
$image_folder "images/days";
// You do not need to edit below this line
$today date('l');

if (file_exists($image_folder."/".$today.".gif")) {

echo ".$today.".gif\">";

}

else {
 
echo "No image was found for $today";

}
?> 

Random image in PHP

Description

Displays a random image on a web page. Images are selected from
a folder of your choice.

The code


/*
 * Name your images 1.jpg, 2.jpg etc.
 *
 * Add this line to your page where you
 want the images to 
 * appear: 
 */ 

// Change this to the total number of images in the
 folder 
$total "11";
// Change to the type of files to use eg. .jpg or .gif
$file_type ".jpg";// Change to the location of the
 folder containing the images 
$image_folder "images/random"; 
// You do not need to edit below this line 
$start "1";$random mt_rand($start$total);
$image_name $random $file_type;
echo "";
?> 

Password protect a page

Description

Password protection for a single page. Visitors are required to enter a password

and username into a login form to view the page content.

The code


// Define your username and password
$username "someuser";
$password "somepassword";
if ($_POST['txtUsername'] != $username ||
 $_POST['txtPassword'] != $password) {?>
 
Login 
 
echo $_SERVER['PHP_SELF']; ?>">

    Username:  
    Password:
   }
else {  This is the protected page. Your private 
content goes here.

}


 

Wednesday, June 9, 2010

Dynamic Currancy Convertion Script

For New Zealanders dealing with people in the US or overseas, we have one distinct disadvantage - our NZ dollar is worth less than an American dollar, so if we price things in NZ dollars, we seem more expensive than we really are.

Of course, the answer is to convert your prices into USD using an automated currency conversion system.