wordpress snippets last updated   : January 28, 2015
we now have 645 snippets
category posts

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

Change wordpress admin post columns order

wordpress snippet

I have needed to move a post column like “date, tags, author” or even a custom column within the wordpress admin. This is a simple method that I used to change the order of columns within the admin. What you have is two variables you will need to change $move and $before. Move is the name of the column you would like to move. Before is the name of the column you would like to move it before. The following snippet will let you move the author column before the post title column.

read more

Track post and page views by user ID, date and time

wordpress snippet

After an interesting conversation with a fan of wpsnipp, I come up with something to track unique post views for registered users. However this neat little snippet does a little more than that. First add wps_trackViewDates(); within the loop of your single.php template file. Once this has been added, the snippet will track the ID of the user that viewed an individual post along with the date and time it was viewed.

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

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