Creating Proper Loop from Unique Main Index Template
-
I need some help to return an individual full length post from an index page that I have created. In my index.php design, the loop code returns two columns that show the most recent single excerpts from two of my main categories. Below is an example of one of my loops for an excerpt on the index page.
<!–the loop–>
<?php if (have_posts()) : ?>
<?php query_posts(‘showposts=1&category_name=interviews’); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_excerpt(‘Read more »’); ?>
<table><tr><td valign=”middle”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><img src=”http://www.slacklineradio.com/images/browsegraphic.jpg”></img></td><td valign=”middle”><h2 id=”post-<?php the_ID(); ?>”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”>Read More of <?php the_title(); ?></h2></td></tr></table>
<div class=”postspace2″>
</div>
<?php endwhile; ?>
<?php endquery-posts; ?>
<?php else : ?>
Not Found
Sorry, but you are looking for something that isn’t here.
<?php include (TEMPLATEPATH . “/searchform.php”); ?>
<!–do not delete–>
<?php endif; ?>
I am not having much success writing the loop for a single post that will return a full length post. Currently, the loop on my single.php is this.
<!–loop–>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!–navigation–>
<!–post title–>
<h2 id=”post-<?php the_ID(); ?>”>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></h2>
<h7><?php the_category(‘, ‘) ?> | <?php the_time(‘F j, Y’); ?> | <?php if(function_exists(‘the_views’)) { the_views(); } ?> <?php edit_post_link(‘Edit’, ”, ”); ?></h7>
<div class=”postspace2″>
</div>
<!–content with more link–>
<?php the_content(‘<p class=”serif”>Read the rest of this entry »</p>’); ?>
<?php
if (is_single()) { echo ”;} ?><!–for paginate posts–>
<?php link_pages(‘<p>Pages: ‘, ‘</p>’, ‘number’); ?>
<div align=”center”><p><?php previous_post_link(‘« %link |’) ?> “>Home <?php next_post_link(‘| %link »’) ?></p></div>
<div class=”postspace”>
</div>
<!–email newsletter and adsense goes here–>
<!–all options over and out–>
<!–include comments template–>
<?php comments_template(); ?>
<!–do not delete–>
<?php endwhile; else: ?>
Sorry, no posts matched your criteria.
<!–do not delete–>
<?php endif; ?>
<!–single.php end–>
This single.php loop returns the string of posts on a more traditional blog homepage and will not return an individual post. I cannot figure out what logic I am missing. My thanks go out in advance for any help in getting my single.php straight.
The topic ‘Creating Proper Loop from Unique Main Index Template’ is closed to new replies.