Usefull wordpress code snippets, hacks and tips

| Last Updated: | In: WordPress, WordPress Snippets


Today i have shared the most Usefull wordpress code snippets, hacks and tips. You can add these code snippets in your functions.php. As a WordPress developer i use very often the same snippets to avoid losing time when creating a new plugin. And today is great day just because i’m going to share some of them with you.

Display Custom Image Sizes in Admin Media Uploader

Add this code in your current theme’s function.php file.

Set Featured Image automatically

Use this code in function.php. Folow the below steps :

1) Select all posts
2) Get first attached images of the posts using get_children() function
3) Use the set_post_thumbnail() function to set the featured image for the posts.

Include the HTML code in widget

Copy and paste this code in function.php and then add html code in your widget.

Empty trash automatically

If you want to empty the trash automatically,then use this code in your wp-config.php.

Post thumbnail in RSS Feed

Add favicon image
Add this code in your function.php file.


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.


You may also like:


,