内容在类别发布模板中的页脚下面被回应

时间:2010-05-03 20:06:21

标签: php wordpress categories

我已在Wordpress中为“博客”类别中的所有帖子创建了一个类别模板。文件名是single-blog.php。 single.php中有一些条件代码可以检查帖子是否属于“博客”类别,如果是,则将其重定向到single-blog.php。这似乎工作正常。

问题在于,在所有单独的“博客”分类帖子中,帖子标题和内容都在页面的页脚下方回显。我不知道为什么他们出现了,我无法阻止或隐藏它。循环在模板页面上关闭,但我想知道来自single.php的循环是否也以某种方式被发送。您可以在此处查看问题的示例:

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

如果您有任何建议,请与我们联系。我将在下面发布两段代码。第一个是single.php中的条件调用。第二个是来自single-blog.php(类别发布模板)的代码。

single.php中的条件调用。

<?php
$post = $wp_query->post;
if (in_category('blog')) {
include(TEMPLATEPATH.'/single-blog.php');
}?>
来自single-blog.php(类别发布模板)的

代码

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

2 个答案:

答案 0 :(得分:1)

您可以尝试添加exit()

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

条件后你的single.php文件中是否有代码?包括不停止执行,解释器将在使用single-blog.php完成后返回single.php文件。

答案 1 :(得分:0)

查看您的页面来源;显示标题“Test Blog Post”的代码在</html>之后,所以你有一个循环或查询或在footer.php中拉帖子的东西