开发者

Wordpress: All Pages on one Page

I'd like to put together a theme that displays all "pages" on a single page. I'm assuming that the best place for this would be "index.php" ... and I want to make sure that my code is the proper way of doing this:

<?php query_posts('post_type=page'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; e开发者_JAVA技巧ndif; ?>

Also, is there a way to optionally NOT display sub-pages?


The easiest way to exclude all sub pages is this:

<?php query_posts('post_type=page'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if ($post->post_parent != '') {
 the_title(); 
the_content(); 
} endwhile; endif; ?>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜