Create WordPress Themes from scratch Part III. Post metadata

If you absolutely beginner , I recomended you to read my previous article about create themes layout and adding sidebar.

Post metadata is information abou posts, include post category post author and posting date.

Open index. php from our latest article, or you can download here. Add the source code bellow and copy inside <div id=”content”></div> tag under post title.

preview Create WordPress Themes from scratch Part III. Post metadatadownload Create WordPress Themes from scratch Part III. Post metadata
<span class="postDate"><?php the_date('F j, Y'); ?> in <?php the_category(', ') ?> by <?php the_author() ?></span>

before

<div id="content">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_content('more'); ?>
</div>
<?php comments_template(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>

after

<div id="content">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<span class="postDate"><?php the_date('F j, Y'); ?> in <?php the_category(', ') ?> by <?php the_author() ?></span>
<div class="entry">
<?php the_content('more'); ?>
</div>
<?php comments_template(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>

Template tags explanation

  • <?php the_date(‘F j, Y’); ?> Is wordpress functions to print the posting date.
  • <?php the_category(‘, ‘) ?> Is wordpress functions to print the category of post. If we have more than one of the category for this posts, we will separate by ‘,’.
  • <?php the_author() ?> Is wordpress functions to print out postauthor.

Wrapping up

Post metadata is important think. With this stuff, reader know who is the author of the post, when this post is posting , and what is the category of the post.

Incoming search terms for the article:

Related Posts

New WordPress Version 3.2 For iOS Now Has Featured Image Support

How To Show An Urgent Message In WordPress Admin Area

Clean Response WordPress Theme

2 Ways To Improve Your WordPress Search Page

2 Comments

  1. RaiulBaztepo

    03.31.2009

    Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language ;)
    See you!
    Your, Raiul Baztepo

  2. mupet

    04.01.2009

    @RaiulBaztepo
    Thanks for visit, I am bad in english to. I am happy to know that you can understand my post.