- Day 1: Introduction, the fundamentals of WordPress theme development
- Day 2: The index.php and style.css files: the most important parts of any theme.
- Day 3: The header.php, sidebar.php and footer.php files.
- Day 4: The single.php file: the file that handles posts.
- Day 5: The archive.php, home.php and functions.php files and a wrap up of all that has gone on. You will also be able to download the whole series as an eBook.
Today, continuing [wp]’s series, [bg], we’ll be developing a file that handles posts – the single.php file. Download the latest copy of the theme we’ve been developing all week, ‘Champion’ with the link above, unzip it and you should notice a couple of new files have appeared! The two new files we need for today’s instalment are the single.php file and the comments.php file. Let’s first look at the single.php file.
Developing the single.php (post Page) file
Upon opening the single.php file, it should look pretty familiar; the first line is <?php get_header(); ?> which, as we learnt yesterday, tells WordPress find the header.php file and display the contents here. Skip a line and you’ll see:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
That too should look familiar; it’s the loop! Scroll down further and you’ll see a couple of template tags –
<?php the_title(); ?>
and