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

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

Display attachment thumbnail with image metadata

wordpress snippet

Adding this snippet within the loop of your index.php template file will display a list of all post attachments with the following metadata (Credit, Camera, Focal Length, Aperture, ISO, Shutter Speed, Time Stamp, Copyright).

read more

Enable Contact form 7 on specified pages only otherwise wp_deregister_script

wordpress snippet

Like many plugins Contact form 7 adds CSS and Javascript to the head of your HTML document. However like many plugins this is done on every single page regardless if the code is required. Adding this snippet to the functions.php of your wordpress theme will let you enable Contact form 7 only on specified pages.

read more

Generate QR Code for posts and pages

wordpress snippet

Have you ever wanted to generate a Quick Response Code / QR code for a post or page of your wordpress website? Simply add this small snippet to the single.php of your wordpress theme in the location you wish to display the QR. To adjust the size of the QR post / page image just change the following within the src size=100×100.

read more

Add search form to specific wp_nav_menu

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will add the search form to your wordpress wp_nav_menu. Don’t forget to update the MENU-NAME to specify the menu you wish to display within, just in case you have multiple menus.

read more

Setup whitelist body_class to remove unwanted classes

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will let you create a white-list of terms to include in body_class. This is a great way to filter out many of the unwanted classes added

read more