the loop (6 posts)

  1. Demetrius Pop
    Posted 2 years ago #

    I am just branching out into template pages and I am trying to get the loop to work in my custom theme. the meta data is showing up but not the content of my post.

    the code:

    Template Name: blog
    <?php get_header(); ?>
    <div id="page-wrap" class="container_12 clearfix">
    <!-- The Loop -->
    <div class="grid_12">
       <? /*Begin Content area Query*/ ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <h2><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute();
    ?>"><?php the_title(); ?></a></h2>
    <small><?php the_time('F jS, Y') ?> <!-- by <?php
    the_author() ?> --></small>
    <div class="entry">
    <?php the_content('Read the rest of this entry »'); ?>
    <p class="postmetadata"><?php the_tags('Tags: ', ', ', ''); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    <?php endwhile; ?>
    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    <?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php get_search_form(); ?>
    <?php endif; ?>
    <!-- End Loop -->
    <?php get_footer(); ?>

    [how to post code: http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

  2. Michael
    Forum Moderator
    Posted 2 years ago #

    you need to tell the loop what to show;


  3. Demetrius Pop
    Posted 2 years ago #

    That works, thanks! :)

  4. Demetrius Pop
    Posted 2 years ago #

    I'm curious as to why you chose query_post as opposed to WP_Query?

  5. Michael
    Forum Moderator
    Posted 2 years ago #

    this does not matter much in a page template where 'query_posts()' is be the only query, and makes it easier to add pagination code.

    of course, the loop can be done with WP_Query().


  6. Demetrius Pop
    Posted 2 years ago #

    I see. Cool, my question actually came from that thread. Small Internet!

Topic Closed

This topic has been closed to new replies.

About this Topic