开发者

Content Being Echoed Below Footer in Category Post Template

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'开发者_如何学JAVA,'','.'); ?>

                </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(); ?>


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜