WordPress内容没有显示

时间:2013-10-10 16:22:23

标签: wordpress

我向header.php添加了一段新代码,现在我的页面内容未显示。

在我的index.php主标记中,我有此代码

            <?php if(!is_home() || !is_front_page) { // dont display on home page

                    if ( have_posts() ) : while ( have_posts() ) : the_post();
                                the_content();
                                endwhile; else: ?>
                                <p>Sorry, no posts matched your criteria.</p>
                                <?php endif;
                    } ?>

现在,自从我的header.php添加以下代码后,我的页面的__tent未显示。例如关于,联系等

<?php
            query_posts('cat=Gallery');
            while (have_posts()) : the_post();
            the_content();
            endwhile;
            ?>

header.php中的代码是获取特定类别的帖子,但现在我的页面内容未显示。我哪里出错?

1 个答案:

答案 0 :(得分:2)

query_posts()替换WordPress检索到的帖子 - 查看the Codex page

请尝试使用get_posts()

在标题循环后调用wp_reset_query()可能也值得,这可以帮助防止意外行为。