There are times when the plugins will not be helping you out in providing you the solution which you are looking for in actual at that time if you know or having some useful snippets – the short code – with you – then you can complete the task easily by adding the code in your theme’s file. With this article, I showcased twenty “must” WordPress snippets.

WordPress

Add Contextual Help Tabs On Any Admin Page

The following snippet will let you create as many help tabs you would be requiring to switching the $screen_id.

Source: WP-Snippets.

Add Custom Image Sizes To Media Insert Dialog

The following snippet will add new image sizes to the Upload/Insert dialog in WordPress. You need to add the code to your functions.php file.

Source: WP-Snippets

Author Bio Excerpt

The following code will let you show a short intro of the author of a post instead of his complete bio.

Automatically Set The Featured Image

The snippet will automatically set the featured image by fetching out the post’s first image.

Check If Sidebar Has Widgets

The following snippet lets you check if a sidebar is having any widget areas into in it or not.

Check If The Visitor Is From Mobile Device

The snippet will let you see that whether your visitor is coming from mobile device or not.

Disable Plugin Updates

The snippet will disable on checking if there is any updates available for your plugins or not.

Finding The First Link In Post

The snippet will let you find the first link in the post and then returns back to you. Using this will allow you to link the title to this place.

Force Direct Update

The snippet will allow you to force direct update for WordPress or plugins. All you have to do is to insert the code into wp-config.php file.

Hide Toolbar When There’s An Error

You need to add the snippet in your functions.php file letting you hide toolbar when there is an error.

Include All Post Types In Search

The snippet will let you include all post types in search.

Override WordPress And Site URL

The snippet lets you override WordPress and site URL by redefining two constants which makes it possible for you to work with production databases.

Source: WP-Snippet

QR code With Article Link

Using the following snippet will let you rendered QR-code for every article.

Redirect User After Login

The snippet will let you redirect user after login. Just add this code to your theme’s functions.php file.

Remove Login Shake

Adding the snippet to functions.php file will let you remove the “wrong password” screen shake.

Remove WordPress Logo From Admin Bar

The following snippet will let you remove the WordPress logo on admin bar. You need to add the code to your functions.php file.

Set Featured Image Automatically

The following snippet will let you set featured image automatically.

Showing Admin Bar To Administrators

Add the code to your theme’s functions.php file to let you hide the admin bar to all logged in users except that of admins. A must for registrations-based sites.

Simple HTML In Widget Title

The snippet will allow you to easily use simple HTML tags in widget title area.

Truncate Post Title

Add this snippet into your functions.php file and whenever you are in need of truncating a title, just call the function.

Source: WP-Snippets

Photo Credit: Flickr/Phil Oakley