开发者

Wordpress: All Pages on one Page

开发者 https://www.devze.com 2023-03-18 20:37 出处:网络
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

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

精彩评论

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

关注公众号