10 Handy Code Snippets For WordPress

Today I would like to share with you 10 very useful WordPress code snippets. The can be used to enhance website security, performance or functionality. They are very easy to use, all to do is just paste in your WordPress theme functions.php file.

You can use them on regular WordPress installation, but remember to make a backup first, because if something is missed (like closing tag) your site can be broken. Also if you are using frameworks like Genesis you'll have to check documentation if snippet is compatible with it.

What is the best about code snippets? Sometimes you can do something without a plugin, what is better for performance and server load.


1. Move WordPress Admin Bar to the Bottom

This snippet is good, if you're frustrated that admin bar is overlaying your site design. Move it to the page bottom and stay calm.


2. Display an author bio excerpt on your WordPress blog

This snippet is good when you want to display only excerpt of author biographical info instead of full one.


3. Spam comments with long URL

This awesome snippet is very helpful if your site is bombed with spam comments. A very time saving code.


4. More from category after content

A very nice snippet that will enhance user experience and also increase page views of your website. Good if you have a lot of traffic on specific pages and want users to browse other posts.


5. Automatically remove short words from URL

Nice code to remove worthless for SEO short words from posts and pages URLs.


6. Remove the url field from WordPress comment form

If you're getting a lot of spam comments this snippet will prevent from linking to other sites just by removing the URL field in comments form. Also is good when you don't want to display links to comment author website.


7. Allow PHP In WordPress Text Widget

Another great snippet that will allow you to put PHP code in WordPress text widget without a need to install plugin that will handle it. Just great!


8. Remove the WordPress Version Info

Wonderful for enhancing security. Crawlers will not recognize your WordPress version.


9. Ads after content

Superb code to display different ads sizes after post content and without a need to use widgets for it! You can also modify this function to increase the number of ads sizes. Also remember that you'll have to add a little of css styling to display it properly.


10. Add featured images to WordPress feeds

Another cool snippet to make your site more attractive and a must if you're using MailChimp with RSS to email newsletter option.

Divi 2.0 WordPress Theme

Like what you read here in this blog post? If yes, please sign up and get latest articles delivered to your email account for FREE! You’ll be also subscribed to newsletter, where I share a exclusive content and offers.

About Kris Hoja

Hi! I'm Kris. For a while I was blogging about WordPress, now I'm owner of HogStudio - Creative Agency focused on website development.
Add me on Google+ and don't forget to follow me on Twitter :)

Leave a Reply