While to help you out in numerous issues revolving all around your WordPress blog, there are hundreds of thousands of plugins available out there, but still what, one definitely need something more. If you have a little (fine) or intermediate (good) or an expert (perfect) knowledge of playing with codes, then the short codes (also known as snippets) will help you ease your job while dealing with issues surrounding your blog. In this article, we have collected such ‘must’ required WordPress snippets. Hope they will be useful for you.


Prevent posts from a particular category to be displayed in WordPress loop

Often times come when you want to exclude certain category of posts from display on the WordPress loop. For excluding such categories, all you have to do is just copy and paste the code below into your functions.php file. But make sure you need to update the code with category ID you want to exclude on line 4.

Source: David Walsh

Search within a specific post type only

The following code will allow you to search only within a specific post type. Just copy and paste the snippet in your theme functions.php file and simply update the code with your post type name on line 4 and you are done.

Source: Hongkiat

Prevent WordPress from asking FTP credentials

Paste the following line in your wp-config.php file and you will be able to prevent WordPress from asking you yours site FTP credentials. The wp-config.php file is located in the root of your WordPress install.

Source: WP Tuts+

Secure your WordPress blog uploads directory

Adding the following code to your newly created file named .htaccess will let you secure your WordPress blog upload directory. The code will let only accept images files, while if in case you want to add any other file type, then make sure you add the file extension to the list on line 5.

Source: Jeff Starr

Easily get post content by ID

You often need to get the content or title from a specific post. The following code will display the content of the post with id $post_id.

Source: WordPress Codex

Display a custom message on WordPress registration page

You often like to display a custom message on your registration page. For doing this, all you have to do is paste the code below in your functions.php file with updating your message on line 6.

Source: Kevin Chard

Empty trash on a daily basis automatically

Simply open your wp-config.php file and add the following line of code and you will notice that WordPress automatically empty the trash on daily basis.

Photo Credit: Flickr/Lindsey Bieda