WP-Mix

A fresh mix of code snippets and tutorials

Auto-Focus Form Fields with jQuery

When you load a page that contains a form, it may be useful to automatically place the user’s cursor in the first form field. This post explains how to do autofocus with jQuery.

WordPress Set Featured Image with Fallback

In this tutorial, we’ll see how to enable theme support for Featured Images (aka Post Thumbnails), and also how to display them with fallback image support.

Basic Code for Image Slider

Here is the basic code required for making a simple image slider. It provides a good starting point for rolling your own sliders, carousels, and so forth.

WordPress Do Stuff on First User Login

Here is a code snippet that runs the first time a user logs in to their registered account. Useful for sending custom welcome emails, or whatever.

jQuery Add Another Image Link

This code snippet is taken from my plugin, User Submitted Posts. It displays a link that users may click to add another file-upload input field.

WordPress Create Upload Files and Directories

This tutorial explains how to create new files and directories in the WordPress /uploads/ folder.

Simple Ajax Chat Test Script

When testing my plugin, Simple Ajax Chat (SAC), I use the following script to save time testing various chat functionality. Posted here in case it’s useful for others. Note this is for the free version of SAC. Enjoy!

Nice little input button with CSS

Just making a note of the CSS used to make a nice little input button, leftover snippet from a previous project.

WordPress Allow HTML in Author Bio

By default, WordPress filters out any markup included in the description (bio) of user profiles. Here is a code snippet to allow HTML in author bios.

jQuery Preview Selected Images

This jQuery script displays a live preview of the currently selected images, as selected from a file input field.

WordPress Check User Roles

Here is a plug-n-play function to check user roles, based on an array of input values.

jQuery Reload Current Page on Click

jQuery makes it easy to do all kinds of cool stuff. For example, here is a code snippet to reload the current page with a click.