(514) 601-1122
joel.dorrington0@gmail.com
I’m gonna scratch down some of my thoughts here for later.
WordPress starts with index.php. It uses this file as the template for the blog page – where you can view all the posts.
header.php is used to store the header template, and is imported with <?php get_header(); ?>.
footer.php is similarly used to store the footer template. It’s imported with <?php get_footer(); ?>.
content.php is the template used to display post samples, and single posts if single.php is not present.
So in index.php, you have “The Loop”. It looks like this: <?php if (have_posts();): while (have_posts()): the_post(); **content.php goes here** endwhile; endif;?>.
That loop checks if any posts were found, then injects a sample of code into place in index.php. the_post(); is the part that sets the context of the injected code to the current post’s data.
You don’t have to put the_post(); into content.php because it’s already in index.php. However, in single.php it’s needed to access the post data. If you don’t include the_post(); the data tags such as the_date(); won’t find any data. the data tags I’ve used so far are simply the following:
the_title(); – This works even without the_post(); for some reason.
the_content();
the_date();
get_permalink(); – returns a string containing the permalink for the post. It should be used in content.php in an anchor tag.
There’s much more about wordpress that I’ve learned but this is enough for now. I should be able to remember the rest.