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.
<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.
2 Comments
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
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.
There are no trackbacks to display at this time.