wordpress snippets last updated   : October 6, 2014
we now have 641 snippets
category functions.php

Require a featured image before you can publish post

wordpress snippet

require-featured-image-can-publish-post

If you would like to require that all posts have a featured image before they can be published add this snippet to the functions.php of your wordpress theme. When you try and publish a post without a featured image you get an admin message “You must select Featured Image. Your Post is saved but it can not be published.” Great way to ensure all your posts have a featured image before they are publish.

read more

Require minimum comment length in wordpress

wordpress snippet

wordpress-require-minimum-comment-length

Add this great snippet by Paul Underwood to the functions.php of your wordpress theme and require a minimum comment length. Anything under the limit will return an error message using wp_die “All comments must be at least 20 characters long.”

read more

Stop Disqus from outputting JS on anything but single posts or pages

wordpress snippet

Disqus outputting JS on parts of your wordpress website you don’t want? Adding this snippet to the functions.php of your wordpress theme will only output JS on is_singular posts or pages where comments are available.

read more

Add body_class to page templates in wordpress

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will let you add a body_class based on a specific page template.

read more

Attach PDF files to post with custom metabox file selection

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will create a new metabox within your post editing screen with a select menu listing all PDF files. Adding the second snippet in your wordpress template in the location you wish to display the files URL.

read more

Change admin post/page color by status – draft, pending, published, future, private

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will change the background colors of the post / page within the admin based on the current status. Draft, Pending, Published, Future, Private.

read more