Snippets

Adding Class to WordPress Post Thumbnail

If the desired output of the default WordPress post thumbnail is not enough you can easily adjust the PHP to output your appropriate class. <?php the_post_thumbnail(‘post-thumbnail’, array( ‘class’ => “YOUR CLASS”)); ?> More information can be found on the codex.

Change Font-Size within Input Field Based on Length

Recently I had a great conversation with an outstanding User Experience designer about a few interactions on a project we were working on. One of the points we talked about was, what should happen when text within input fields are excessively long.

The desired result we both agreed on was to change the font size on the fly. Thankfully this is extremely easy with a little bit of jQuery that listens to events on the input field.

So if you happen to be in the same situation hopefully these snippets should get you heading down the right track.

Add Shortcodes in Widgets

If you use shortcodes within your WordPress theme you might need to also add them within your widgets. This little snippet does the trick.

Remove Telephone Styling in iOS

Viewing telephone numbers on iOS device can provide an unpleasant shock. They tend to render in a default blue colour making your designs look broken.

Adding Toolbar Menus in WordPress

If developing themes or plugins for WordPress sometimes it is handy to add a menu item to the WordPress admin bar to help quickly reference the desired action.

You can do various things with the admin bar but this snippet should help you get started.

Exclude IP Address From Google Analytics

If you have installed Google Analytics on your site, or for a client it is always helpful to exclude IP addresses so the sites stats give an accurate representation of the real traffic.

Styling Placeholder Text

Sometimes the light grey placeholder text needs to be styled to fit with your needs. All in all it is pretty easy with a couple of pseudo-elements and pseudo-classes.

Checkbox Checked in YUI

If you happen to need to trigger an event when a checkbox is checked or unchecked with YUI then this little snippet should help you out.

1234