WordPress Customization
By Justin Laing2008-01-09
![]()
Maybe you want to display an ad at the bottom of each post, or perhaps
you’d like to add or remove the author information under the post
header? The place to do these things is in the single.php file. This
file controls the layout of your individual post pages.
Let’s examine the components of this file for the default WordPress theme:
<?php get_header();
?>
<div id=”content”
class=”widecolumn”>
<?php
if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class=”navigation”>
<div
class=”alignleft”><?php previous_post_link(’« %link’)
?></div>
<div
class=”alignright”><?php next_post_link(’%link »’)
?></div>
</div>
<div
class=”entry”>
<?php the_content(’<p
class=”serif”>Read the rest of this entry »</p>’);
?>
So how do I add some author information and maybe date of the post to this?
It’s easy! There’s a lot of information stored with each post
that is accessible within “The Loop”. To see a list of all the
functions you can use to get at this information visit this
documentation page: http://codex.wordpress.org/Template_Tags.
There you’ll see all the template functions that are available to you.
So to get the author of the post we’d just call the_author();. Of
course we’d want to put some HTML formating around it so we might do:
<p>This post was written by <?php
the_author(); ?></p>
Now to put the date the post was written we could put:
<?php the_date(’Y-m-d’,
‘<h2>Published On ‘, ‘</h2>’); ?>
There are tons of stuff you can do with posts so check out: http://codex.wordpress.org/Template_Tags and get started.
Tutorial pages:
|
Originally posted on Makebeta
|
|||||||||
Link to This Tutorial Page!

