Wordpress博客没有显示帖子。添加自定义投资组合后期字段会影响这个吗?

时间:2012-04-12 21:47:18

标签: wordpress wordpress-theming

现在我已经完成了其他几次没有问题,我有一个主页面使用home.php和博客作为另一个页面使用“blog-home.php”博客模板与所有正确的代码来抓住帖子但它没有显示。唯一的区别是我在功能中添加了一个自定义组合后置字段,这会影响它还是可能是其他东西?我可以在最新发布的帖子下从主页访问帖子,将代码放在下面,但就是这样。

<?php query_posts("post_per_page=1"); the_post(); ?> 
  <p><?php the_excerpt(); ?></p>
  <?php wp_reset_query(); ?></div>

* 更新:我尝试了另一个代码,但现在只将博客页面显示为帖子。 *

<?php

/*
    Template Name: Blog Home
*/
?>
<?php get_header(); ?>
<div id="contentwrapper">
<?php query_posts( array ( 'category_name' => 'Blog', 'posts_per_page' => 5   ) ); ?>
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
                <div class="blogentry">
                <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>  </h4>
                <?php the_content(); ?>
                    <div class="postmetadata">
                        <?php the_tags('Tags: ', ', ', '<br />'); ?>
                    </div>
                <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
                </div>

            </div>

            <?php endwhile; ?>

            <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>

            <?php else : ?>

            <h2>Not Found</h2>

            <?php endif; ?>


</div>



<?php get_footer(); ?>

1 个答案:

答案 0 :(得分:0)

也许你使用

$posts = get_posts(array('numberposts' => 1));
global $post;
$post = $posts[0];
the_excerpt();

而不是

query_posts();

如果get_posts不适用于你尝试使用WP_Query()

,那么改变全局查询永远不是一个好主意
相关问题