X

How to Replace Current Loop With Microformatted and HTML5 Compliant Loop

Snippets by IsItWP

Are you looking for a way to replace your existing WordPress loop with a microformatted and HTML5 compliant loop? While there’s probably a plugin for this, we have created a quick code snippet that you can use to replace your current loop with microformatted and HTML5 compliant loop in WordPress.

Instructions:

All you have to do is add this code to your theme’s single.php file or in a site-specific plugin:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <article class="post hentry hnews"><!-- START OF POST -->
          
<h1 class="entry-title url"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>

<span class="meta"><time class="updated" datetime="<?php
$postDate = get_the_date('c');
$postDate2 = get_the_date('d.m.Y');
echo $postDate ?>" pubdate>
<?php echo $postDate2; ?></time> | <span class="byline vcard"><span class="fn author"><?php the_author();?></span> | <?php the_category(''); ?></span> | <span class="org"><?php bloginfo('name'); ?></span></span>
     <div class="postContent entry-content">
     <?php the_content(); ?>
     <p class="postmetadata">Posted in <?php the_category(', '); ?> | Tags: <?php the_tags(); ?></p>
     </div>
                </article><!-- END OF POST -->
<?php endwhile; endif;?>

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 18 Jetpack alternatives to get the features and how to create a file upload form in WordPress.

Comments  Leave a Reply

  1. Antonin Januska October 24, 2011 at 4:21 pm

    Author here. Actually found a syntax error in the loop (it’s minor). Where it says: <span class"org"><?php bloginfo(‘name’); ?></span> add an equal sign between “class” and “org” and add a closing span tag afterward (I left it open by accident).

    Anyways, hope someone makes use of this!

    1. Antonin thanks made the update,

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!