Few simple yet useful WordPress Tweaks
These are very easy to do stuffs, nothing complex, yet, in time you will find it useful. Most no-tech bloggers intend to do everything through plug-ins, but why install dozens of plug-ins while you can get away with just adding a few tweaks? So here are a few, simple WordPress Tweaks that will make your WP life a lot more comfortable.
Denying access to non-referrer request/Spam-bot request via .htaccess
This is a simple and straightforward way to deal with your referrer spam. Well, of course, considering your server is Apache with mod_rewrite module installed. Since all the games played in the wp-comments-post.php file and spam-bots usually don’t leave a referrer, we can detect and deny their access to wp-comments-post.php file by just using these few lines on .htaccess file (located on the root WordPress installation directory). If you don’t have any .htaccess there but your server does support one, you can just create one on notepad (save as->file name- .htaccess, save as type-all files) and upload it via FTP. Don’t forget to replace *myblog.xxx.*(on line 3) with your own domain name, remember no www or http://
Code below (copy each line without numbers at the beginning of each line).
1 RewriteEngine On RewriteCond %{REQUEST_METHOD}
2 POST RewriteCond %{REQUEST_URI} .wp-comments-post\.php
3 RewriteCond %{HTTP_REFERER} !.*myblog.xxx.*
4 [OR] RewriteCond %{HTTP_USER_AGENT} ^$
5 RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
Custom permalinks
Undoubtedly, the best one suggested by SEOs. This tweak requires you to change the default page title from (www.yourdomainname.com/?p=1) to a much SEO and user friendly www.yourdomainname.com/category/page title.
This can be done by following the two simple steps.
1) Go to Options > Permalinks
2) Change the default setting to custom with the following code – /%category%/%postname%/
Showing tag cloud
There are quite a few plug-ins out there that not only show tag cloud but do pretty much all other things as well. But just for showing tag cloud, installing/using those plug-ins is redundancy, while WordPress got its own template tags to do this simply.
What you have to do is just place the following piece of code in your WordPress theme file (ex: Sidebar.php) where you would like the tag cloud to be shown.
< ?php wp_tag_cloud(''); ?> ;
(without those spaces in front and at the end)
You can use CSS to do the styling. These template tags got some parameters that will allow you to do further customizations as well. The parameters are:
Smallest: (integer) The font size for the tag with the smallest count value. Remember, just number, no px or em here.
largest: (integer) The font size for the tag with the highest count. The same like previous numbers only.
unit: (string) This is where you declare the Unit of measure of the smallest and largest font size you declared earlier. This can be – pt, px, em, %; default is pt (points).
number: (integer) How many tags to show in tag cloud, place 0 for all, which is default by the way.
format: (string) the types of the cloud display. There are three flat (default tags are separated by white space), list (tags are separated by li), array (tags are all in an array – every tag is an element of that array).
order by: (string) This is where you define how you would like to display the tags within the cloud. There are two options here; name (default) or count (no. of posts have the same tag).
order: (string) Here you define the sort order, i.e descending (DESC) or ascending (ASC).
exclude: (string) By default, this parameter doesn’t hold any value. This is for excluding certain tags that you want to exclude from the cloud. Just place the term_id (Tag id) separated by commas.
Include: (string) The same like above comma separated term_id, the difference is that the function is just opposite.
Example usage:
< ?php wp_tag_cloud('smallest=7&largest=25&unit=pt&number=20&format=li&orderby=count&order=DESC&exclude=7,5'); ? >
That’s all for the day. Come back later for more WordPress Tweaks.