wordpress snippets last updated   : October 6, 2014
we now have 641 snippets

Redirect commenter to thank you post or page

wordpress snippet

Why not thank your visitors! Let them know they are important by redirecting them to a thank you page where you can display a great big thank you for commenting on my wordpress site message. Adding this snippet to the functions.php of your wordpress theme will redirect a commenter to any post or page you specify. To update the snippet to a page change wp_redirect('/page/'); replace /page/ with whatever page you would like eg: wp_redirect('/thank-you/');.

read more

Display last months most commented posts as thumbnail

wordpress snippet

This snippet will display last months most commented posts as thumbnails. Add the first snippet to the functions.php of your wordpress theme then add the second snippet where you wish to display the thumbnails. I currently use this snippet on http://wpsnipp.com after the third post if you wanted to see it in action.

read more

Highlight comments using #comment-hash and jquery

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will add class=”highlight” to a comment when visiting a comment URL eg: wpsnipp.com/category/post/#comment-12 Don’t forget to create some css for the highlight class!

read more

Display user comment count next to username

wordpress snippet

Add the first snippet into the functions.php of your wordpress theme. Open up your comments.php template and place the second snippet commentCount() in the location you wish to display each users comment count.

read more

Replace admin and user comment class

wordpress snippet

Wordpress creates a class name for your comments using your username and for security reasons you may wish to change them. Adding this snippet to the functions.php of your wordpress theme will remove and replace the admin and user class names within your comments.

read more

Deny comment no referrer requests

wordpress snippet

Adding this PHP code to the functions.php will check the referrer when a user posts a comment to ensure they are not a BOT. Thanks to Joost de Valk for this little snippet,

read more