wordpress snippets last updated   : January 27, 2015
we now have 644 snippets

Remove the_post_thumbnail class

wordpress snippet

Have you ever been using the_post_thumbnail( 'thumbnail' ); but wanted to remove the class that is automatically added. Add the following snippet to the functions.php of your wordpress theme to automatically remove any class. Simple but effective,

read more

count_user_posts by user ID and by post_type

wordpress snippet

You may be aware that count_user_posts has been around since about 3.0. However as of 4.1 you are able to optionally define a post_type. This is a perfect little snippet if you have a blog with multiple post types and you wanted to show specific counts for authors. I could use something like this for WordPress snippets vs tutorials sections and it would be perfect. Just add this snippet in the template you wish to display the count and you are ready to go.

read more

Customize Comment Count Text

wordpress snippet

You can customize the text for displaying the number of comments inside the loop. This is just a simple template edit however it is extremely useful if you are creating a theme that is not a traditional theme or you wanted to inject a little bit of personality into the site.

read more

Show or Hide widgets on specific pages

wordpress snippet

Want to show or hide widgets on specific pages? This is a great little snippet contributed by Joel Worsham that will do just that. You will first need to get the id name of the widget that you wish to define. You can do this be viewing the page source or using a web inspector tool to view the widget id. The current sample is setup to only display the core ‘pages’ widget on the contact page only. Don’t forget that is_page also accepts an array of page names and id’s.

read more

Sharpen Resized WordPress uploaded Images (jpg only)

wordpress snippet

This great snippet by Unsal Korkmaz that will sharpen resized images uploaded to wordpress (jpg only). This is a great way to fix blurry jpg thumbnail images. If you would rather use this as a plugin you can now download it from the WordPress plugin directory.

read more

Add and remove wordpress user roles

wordpress snippet

With WordPress you can add and remove roles very easily. The first snippet will add a new role called “manager” with some basic capabilities. You can view the WordPress roles and capabilities page for more extensive details on the capabilities available that you can assign to a custom role. The second snippet will remove some of the existing roles “editor, author, contributor, subscriber” however this could also remove a custom role. NOTE: if you remove an existing role it will be gone! So please be careful when removing roles.

read more