wordpress snippets last updated   : September 29, 2014
we now have 639 snippets

Create page on theme activation

wordpress snippet

If you are creating a new theme either for sale of for a client you may want to have it create a custom page or pages when the theme is activated. Adding this snippet to the functions.php of your theme will do just that.

read more

Block admin for all users but administrator

wordpress snippet

If you need to block all users but the administrators from wp-admin just add this snippets to the functions.php of your wordpress theme. This snippet will redirect everyone but the admin back to the primary domain.

read more

Remove width & height attributes from images in posts

wordpress snippet

Looking to remove the width and height attributes from images in your posts? Is this because you are using a responsive wordpress theme. Just add this snippet to the functions.php of your wordpress theme and all of the width and height attributes will be removed from your images.

read more

Add a Logo or Image to a Template

tutorials
add-logo-image-template

It is common for WordPress themes to allow you to customize the header graphic, or even upload your own logo, nevertheless, there are times when you just need to add an image tag into a template. It may seem easy, but WordPress beginners can be confused as to where to upload the image, and how to write the path to it.

read more

List All Available wordpress Roles

wordpress snippet

Here is a snippet showing how to list all available roles. I recently used this snippet to add a role selector in the registration page. You could also use it for user searches, or post filters.

read more

Display post attachment count in admin column

wordpress snippet

Sometimes you have a post with multiple attachments and it would be nice to see a count of the total media attached to a post. Adding this snippet to the functions.php of your wordpress theme will display the post attachment count in a custom admin column.

read more