Example Form Markup

<form id="myForm" action="#" method="post">

  <div>
    <label for="name">Text Input:</label>
    <input type="text" name="name" id="name" value="" tabindex="1">
  </div>

  <div>
    <h4>Radio Button Choice</h4>

    <label for="radio-choice-1">Choice 1</label>
    <input type="radio" name="radio-choice" id="radio-choice-1" tabindex="2" value="choice-1">

    <label for="radio-choice-2">Choice 2</label>
    <input type="radio" name="radio-choice" id="radio-choice-2" tabindex="3" value="choice-2">
  </div>

  <div>
    <label 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Empty Table Markup

<table>
	<thead>
		<tr>
			<th></th>
			<th></th>
			<th></th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
	</tbody>
</table>
Avatar of Chris Coyier
Chris Coyier on

Basic SimplePie Usage

You’ll need a of copy SimplePie for the include right at the top here.

<?php
    require_once('inc/simplepie.inc');
    
    $feed = new SimplePie();
    
    $feed->set_feed_url(array(
    	'http://search.twitter.com/search.atom?q=movie'
    ));
    
    $feed->enable_cache(true);
    $feed->set_cache_location('cache');
    $feed->set_cache_duration(15);
    
    $feed->init();
    
    $feed->handle_content_type();

    if ($feed->error): ?>
    
        <p><?php echo $feed->error; ?></p>
        
    <?php endif; ?>

    <?php foreach 
Avatar of Chris Coyier
Chris Coyier on

Lorem Ipsum Paragraph

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend …

Avatar of Chris Coyier
Chris Coyier on

Build a Calendar Table

<?php

function build_calendar($month,$year,$dateArray) {

     // Create array containing abbreviations of days of week.
     $daysOfWeek = array('S','M','T','W','T','F','S');

     // What is the first day of the month in question?
     $firstDayOfMonth = mktime(0,0,0,$month,1,$year);

     // How many days does this month contain?
     $numberDays = 
Avatar of Chris Coyier
Chris Coyier on

Force Favicon Requests to Correct Location

For whatever crazy reason, perhaps evil-doing site scanners, requets to a web server for a favicon in all known crevasses of the site are fairly common. Since that file probably only actually exists in the root directory of your site, …

Avatar of Chris Coyier
Chris Coyier on

301 Redirects

This is the cleanest way to redirect a URL. Quick, easy, and search-engine friendly. Remember HTAccess stuff is for Apache servers only.

Redirect a single page

Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html http://www.yoursite.com/folder/

Redirect an entire site

This way …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

If Page Is Parent or Child

There are built in conditional WordPress functions for testing for a page:

if ( is_page(2) ) {
  // stuff
}

Or for testing if a page is a child of a certain page:

if ( $post->post_parent == '2' ) {
  
Avatar of Chris Coyier
Chris Coyier on

Empty an Array

This is one of the fastest and easiest ways of emptying an array. Of course there are may other ways, but those usually include creation of a new array. This way you reuse the same array.

var myArray = ["one", 
Avatar of Chris Coyier
Chris Coyier on