Template Help (4 posts)

  1. b3ndy
    Posted 8 years ago #

    Hello everyone,

    Firstly this is a great forum, I have been using it loads for all my wordpress fun! Apologies if this question has been posted before, I did do a pretty good search and didn’t manage to find anything.

    I am trying to create a wordpress skin for my companies Press Releases, what I really want to do is have two pages, a title page listing the story title and date, then, a page that displays the full story.

    This could be the simplest template ever, but I am a complete php n00b I am afraid.

    I am using the following code on the main template:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <?php the_date('','<h3>','</h3>'); ?><div class="post" id="post-<?php the_ID(); ?>">
    <h3 class="storytitle">/<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></h3>

    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    which is displaying the titles, but how do I create a second page that displays the full story when the title is clicked?

    Many thanks for all your help,


  2. moshu
    Posted 8 years ago #

    If by skin you meant a theme (we don't like the word "skin" ;) - then simply create a single.php template file with a Loop that has the_content tag. (see how it is done in the default theme and many other themes)

  3. b3ndy
    Posted 8 years ago #

    Hi, thanks for the reply, my bad, I mean theme!

    Looking at the default theme, but still a little confused as how to do this! Any advice?



  4. moshu
    Posted 8 years ago #

    It is quite simple, see the Template Hierarchy:
    Whenever a specific template file is missing - WP falls back to index.php.
    Since in your index (aka main template) you don't have the_content tag - it will never display the text of a post.
    For displaying a single post, use/create a template file called single.php. WP will do the rest: it recognizes the specially named template files.

Topic Closed

This topic has been closed to new replies.

About this Topic