Wordpress页面内容未显示

时间:2011-11-23 14:08:09

标签: wordpress custom-post-type

我在wordpress自定义帖子类型页面上遇到一个小问题,其中下面的页面内容似乎从其中一个自定义帖子类型输出最后一段内容。代码如下。

我们希望将页面内容移动到自定义帖子类型下方,因此将get_template_part( 'content', 'page' );函数移动到自定义帖子循环下方。当此函数位于循环之上时,页面内容正确输出,但高于自定义后循环(即不符合要求)。

我知道修复可以修复,但如果是这样,请你指点我正确的方向吗?

<div id = "feature_boxes_wrap2">
                <?php query_posts(array(
                            'posts_per_page' => 3,
                            'post_type'=>'feature_box'
                            )
                          ); ?>


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


                <div class = "feature_box2">
                    <?php echo get_the_post_thumbnail($id, array($image_width,$image_height)); ?>
                    <h2 class="feature2"><?php the_title();?></h2>
                    <?php $feature_content = get_the_content(); ?>
                    <?php echo substr($feature_content, 0, 100); ?>
                    <br>
                    <a href = "<?php g5_print_page_link(); ?>">Read more</a>
                </div><!-- #feature_box2 -->

                <?php endwhile; // end of the loop. ?>
            </div><!-- #feature_boxes_wrap2 -->


            <?php
            the_post(); 
            get_template_part( 'content', 'page' ); ?>

1 个答案:

答案 0 :(得分:2)

在这里,试试这个:

在致电 wp_reset_query()之前添加 the_post(); [...],这应该可以解决问题。 有关详细信息:http://codex.wordpress.org/Function_Reference/wp_reset_query