Adding microformat attributes to a WordPress theme is an easy way to add more semantic metadata to your markup, which in turn makes a website more functional. Microformat data are beneficial because it makes is much easier for your site’s information to be parsed and used in other applications, for instance search engines.

We will need to format the date and time to follow the ISO 8601 standard using the WordPress template tag, the_time.

The specific tag we want to get the ISO format is <?php the_time('c'); ?>, which will output in our code like this: 2011-06-22T21:59:08+00:00.

Keep in mind that the datetime attribute is only shown in your code, so we then need to use a template tag like <?php the_time('F j, Y') ?> to output something visible, which in this case would show as June 27, 2011.

Here’s the code together that contains the timedate meta data:

1
<time datetime="<?php the_time('c'); ?>"><?php the_time('F j, Y') ?></time>

And here’s an example of a structure that could be used for a post in the WordPress loop:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<article>
    <div class="meta">
        <time datetime="<?php the_time('c'); ?>">
            <?php the_time('F j, Y') ?>
        </time>
    </div><!--end meta-->

    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>

    <div class="excerpt">
        <?php the_excerpt(); ?>
    </div><!--end excerpt-->

     <a class="read-more" href="<?php the_permalink(); ?>">Read more</a>
</article>