CSS Print Media Query

Using the @media rule in your CSS allows you to target different media types, and screen sizes, from a single stylesheet. Using media queries with max-widths is integral to the current push towards responsive design. This can also be used to create your print styles using @media print. You'll notice this used on modern base-templates such as the HTML5 BoilerPlate:

Add a Subscribe to MailChimp Newsletter Option on Your Contact Form in 5 Minutes

Adding a “Subscribe to Newsletter” checkbox or radio button to an existing contact form is incredibly painless using the MailChimp API. Include one library file, and you’ll have access to all functions the API has to offer. In this example, I added a Yes/No radio selection. You could easily change this to be a checkbox. When "Yes" is selected, and the form is submitted, the contact form does its thing, and then the user is added to a MailChimp List.

Quick and Simple CSS Percentage Bar using PHP

If you have some PHP numbers you need to work with, creating a percentage bar is incredibly simple. Calculate the percentage, and then set a width on a DIV that can then be styled. To set this up quickly, I set the percentage bar to 100 pixels wide. For posting this, I've added a scale factor in case you want to make the percent bar wider.

Check if Email Username Exists with CodeIgniter and jQuery Validation Plugin

A common feature of most new user registration forms is a message telling you whether your chosen username or e-mail is already taken. The check is done through an AJAX request. Using the jQuery Validation plugin, the remote option can be used to request a URL that returns JSON data. Using CodeIgniter, this URL is a new function in the controller used for registration. In this example, the register_email_exists() function returns true or false, after checking the entered form value against the database. See the following example code for the basic PHP and JavaScript you'll need to make this work.

jQuery One-Liners and Reuseable Code Snippets for Common Tasks

For the last few weeks I've been collecting tiny morsels of jQuery and straight JavaScript that I've needed for building sites. I had found myself needing the same small scripts over and over. Rather than rewriting and checking an API/plugin reference, now I can just copy from this list. Most of these snippets are a few lines each. Some are simple. Some aren't.

Create a New WordPress Admin User from PHP

If you're locked out of WordPress and can't reset your password, the official docs list several options that allow you to access your administrator account again. But what if you want to create an entirely new admin user? For blogs that I have FTP access to, but no working WordPress password, I threw together the following script to create admin users.

Using Custom Post Types for Repeated Content/Includes in WordPress

Most sites contain areas of text and HTML that are repeated throughout the site. Links in the footer, copyright information, a button or phone number in the header, or some other static content. If you're a developer working on your own site, then you may just keep this in an include file and edit the code manually. If you're using Wordpress as a CMS for a client, then it's a good idea to make these areas of text/images editable, so that they can have full control of their site.