views:

33

answers:

2

I have created a category template in Wordpress for all posts that are in the 'blog' category. The file name is single-blog.php. There is some conditional code in single.php that checks whether the post is in the 'blog' category and if it is it redirects it to single-blog.php. That seems to be working fine.

The problem is that on all the individual 'blog' categorized posts the post title and content are echoed below the footer of the page. I do not know why they are showing up and I haven't been able to stop it or hide it. The Loop is getting closed on the template page, but I'm wondering if the Loop from single.php is somehow also being sent over. You can view an example of the problem here:

http://69.20.59.228/2010/03/test-blog-post/

Please let me know if you have any suggestions. I am posting two sections of code below. The first is the conditional call in single.php. The second is the code from the single-blog.php (the category post template).

the conditional call in single.php.

<?php
$post = $wp_query->post;
if (in_category('blog')) {
include(TEMPLATEPATH.'/single-blog.php');
}?>

code from the single-blog.php (the category post template)

   <?php get_header(); ?>

   <?php get_sidebar(); ?>


   <p><h2>The IQNavigator Blog</h2></p>
   <em><a href="/category/blog">Blog Home</a></em> | <em><a href="/category/blog/feed/">Subscribe via RSS</a></em><p><br></br></p>

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


    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
        <h1 class="pagetitle"><?php the_title(); ?></h1>
        <!-- <p class="details">Posted <?php the_time('l, F jS, Y') ?> at <?php the_time() ?></p> -->
        <div class="entry">
            <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>

            <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
            <?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>

            <p class="postmetadata alt">
                <small>
                    -----<br>
                    Posted
                    <?php /* This is commented, because it requires a little adjusting sometimes.
                        You'll need to download this plugin, and follow the instructions:
                        http://binarybonsai.com/wordpress/time-since/ */
                        /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?>
                    on <?php the_time('l, F jS, Y') ?>, 
                    filed under <?php the_category(', ') ?>.
                    Follow any responses to this entry through the <?php post_comments_feed_link('RSS'); ?> feed.

                    <?php if ( comments_open() && pings_open() ) {
                        // Both Comments and Pings are open ?>
                        <a href="#respond">Leave your own comment</a>, or <a href="<?php trackback_url(); ?>" rel="trackback">trackback</a> from your own site.

                    <?php } elseif ( !comments_open() && pings_open() ) {
                        // Only Pings are Open ?>
                        Responses are currently closed, but you can <a href="<?php trackback_url(); ?> " rel="trackback">trackback</a> from your own site.

                    <?php } elseif ( comments_open() && !pings_open() ) {
                        // Comments are open, Pings are not ?>
                        You can skip to the end and leave a response. Pinging is currently not allowed.

                    <?php } elseif ( !comments_open() && !pings_open() ) {
                        // Neither Comments, nor Pings are open ?>
                        Both comments and pings are currently closed.

                    <?php } edit_post_link('Edit this entry','','.'); ?>

                </small>
            </p>




            <?php the_tags( '<p>Tagged: ', ', ', '</p>'); ?>
        </div>

    </div>


<?php comments_template(); ?>

<?php endwhile; else: ?>

    <p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>


<?php get_footer(); ?>
A: 

Look at your page source; the code displaying the title "Test Blog Post" is after </html>, so you've got a loop or query or something pulling posts in footer.php

songdogtech
I saw that; but my footer code does not have that anything to do with the loop. Here's the exact code that is in the footer (pastebin): http://wordpress.pastebin.com/zfQ4GHBZThe extra loop is being injected or repeated from an unknown source.
poindexter
Is single.php empty except for what you posted?
Fletcher Moore
single.php is almost the same as what I posted, except it doesn't have the "blog header" HTML or the code allowing people to post comments. You can see exactly what is in single.php here: http://wordpress.pastebin.com/nqLQdtLE
poindexter
+1  A: 

You could try adding exit()

 <?php get_footer(); exit(); ?>

Is there code in your single.php file after the conditional? Includes do not stop execution and the interpreter will return to the single.php file after it is done with single-blog.php.

Fletcher Moore
There is code in the single.php after the conditional; what you are describing is what I was afraid of. Should I unwrap your code and place it within the conditional wrapper before the php tag closes?
poindexter
Alright, I put your code in and it is fixed. Thank you very much, answer accepted.
poindexter
In PHP you can use exit() at any time to stop the code completely. So if there is no way to better organize your code, I would just put it after the include statement in the conditional.
Fletcher Moore
thank you, that's a very helpful bit of knowledge. :)
poindexter