With the way WordPress has made its place in our lives is awesome. Almost every second or third website you found on internet is a WordPress website, then whether it would be a blog, a corporate or something else. In short, WordPress speaks the language of making big your brand.


But still with all this, have you ever tried to think that all these sites have something in common – yes I know they all are WordPress websites – but what else? If you noticed correctly, all these websites from time to time require some short snippets (code) – just like your car requires fuel – which helps you in creating and customizing your website better.

The list that I am going to share through this article is a pretty comprehensive list of useful snippets for WordPress. These all snippets should work across all versions of WordPress. So, here we go – the ten very useful WordPress Snippets:

Checks If The Visitor Is From Mobile Device

The purpose of this snippet is to check whether if the user is visiting using a mobile device or not and also in return if it would be returning results in either true or false.

Remove Login Shake

The following snippet has to be added to functions.php and it will remove the “wrong password” screen shake.

Only Show Admin Bar To Administrators

To hide the admin back to logged in users except admins, add this snippet in your theme’s function.php file. This snippet is basically useful for sites having public registration turned on.

QR Code With Article Link

To have the QR-code rendered for every article, just insert the following snippet inside the WordPress loop.

Disable All Comments

Although you do have an option to disable all the comments in a single go via your WordPress dashboard area but you can also do the same via using the snippet. You can do this by using this MYSQL snippet in your database.

Detect iPhone Users

With the way mobile has entered in our day to day lives, the use of mobile web is also on increase. It’s a good idea to customize your website for mobile browsers. The following snippet will helps you detect visitors which are using an iPhone, allowing you to create a better experience for them.

Check PHP Version

Since WordPress 3.2 version made its debut, PHP 5.2.4 is required for it to run. The time ever since development of plugins for this version come into existence you might require to check that whether the PHP version is up to date or not.

Custom Admin CSS

One in Five times you would be interested in changing the default style of WordPress area. In order to do this, you have to create a new css file in your theme folder and then have to include this in WP-Admin using the admin_head hook. As soon as you are done, add this to functions.php template, change paths and then add the stylesheet in the place where it is require and you are then free to add whatever styles you want to override with.

Define Widget Area In Post Or Page

Often you feel the sense that you would be requiring more separate widget areas for your particular page as well as post you are on. At that time, instead of building a new template, it would be better to add a custom filed to each of this page or post you want to have a different sidebar on.

Hide ‘Screen Options’ Tab

If you hated the way the Screen Options tab appearing in front of you in your admin area, then adding this snippet to your functions.php template will do the trick for you. Simply add it.