wordpress snippets last updated   : October 6, 2014
we now have 641 snippets

Microformatted and HTML5 compliant loop

wordpress snippet

Why not replace your existing wordpress loop within your theme to a microformatted and HTML5 compliant loop.

snippet :  PHPcopy
<?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;?>

Did you like this post? If so please share it with your friends. Thanks!

  • http://twitter.com/AntJanus Antonin Januska

    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!

    • http://wpsnipp.com Kevin Chard

      Antonin thanks made the update,

jqsnipp.com | we just launched jquery snippets website