wordpress snippets last updated   : August 18, 2014
we now have 638 snippets
category functions.php

Add post category to body_class on single posts

wordpress snippet

This little snippet will take all the categories assigned to a post and add them to the body_class “sgl-cat-{category-name}”.

read more

Insert calendar into wp_nav_menu

wordpress snippet

Needed this for a recent project as a client wanted to display the wordpress calendar as a dropdown item within the menu. Add this snippet to the functions.php of your wordpress theme will add a new menu item to your wp_nav_menu that has a submenu calendar.

read more

Change title attribute of wordpress login logo

wordpress snippet

This little snippet will change the title attribute text when you hover over the wordpress logo on the login page. If you want to replace the logo take a look at this snippet it will remove the wordpress logo.

read more

Add custom image sizes to media insert dialog box with image_size_names_choose

wordpress snippet

With this little snippet you can add custom image sizes to media insert dialog box. image_size_names_choose allows modification of the image size lists so that you can place a custom option within the media library.

read more

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