Recent Tutorials

Display Full Content Of The Most Recent Post and Others With Excerpts

We’ll use a WordPress loop to do this. First, we need to add a variable $count which will count how many posts are listed.

Paste the below codes in the current loop. You can change $postnumber variable to set the maximum posts should be showed.

1
2
3
4
5
6
7
8
9
10
11
<?php
    $postnumber = 5; //maximum number of posts to show
    if(have_posts()) : $count = 0;
        while (have_posts()) : the_post();
            $count++;
            if ($count < $postnumber) : the_content();
            else : the_excerpt();
            endif;
        endwhile;
    endif;
?>
<?php
	$postnumber = 5; //maximum number of posts to show
	if(have_posts()) : $count = 0;
		while (have_posts()) : the_post();
			$count++;
			if ($count < $postnumber) : the_content();
			else : the_excerpt();
			endif;
		endwhile;
	endif;
?>

Disable Hotlinking Using .htaccess For WordPress Sites

Hotlinking is the use of an image from one site into a web page belonging to another site. Many bloggers are hotlinked, and have their bandwidth used on another websites. Here’s a solution to protect your WordPress blog from hotlinking.

The first thing to do is to upload an image saying like this one:
Hotlinking Dis-Allowed!

Then, edit the .htaccess file, located in your WordPress root directory (usually named “public_html”). Remember to backup existing .htaccess file before modifying.

Append this code to the existing .htaccess:
1
2
3
4
5
6
RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]

* If no .htaccess file exists in the root directory, then just create a new one & add the above code in it.