您可以根据网站的;首页显示;正在读取设置show_on_front
和page_on_front
.
在那里,您将能够在索引上显示帖子,并在其他位置显示页面:
<section id="two">
<div class="inner">
<?php
if ( is_home() || is_front_page() ) {
$post_type="post";
}
else {
$post_type="page";
}
$pagesargs = array(
\'posts_per_page\'=> 2,
\'offset\'=> 0,
\'category\' => \'\',
\'category_name\' => \'\',
\'orderby\' => \'post_date\' ,
\'order\' => \'DESC\',
\'include\' => \'\',
\'exclude\' => \'\',
\'meta_key\' => \'\',
\'meta_value\' => \'\',
\'post_type\' => $post_type,
\'post_mime_type\' => \'\',
\'post_parent\' => \'\',
\'post_status\' => \'publish\',
\'suppress_filters\' => true,
);
if ( is_home() || is_front_page() ) {
$my_pages = get_posts($pagesargs);
}
else {
$my_pages = get_pages($pagesargs);
}
foreach ($my_pages as $page){
?>
<article>
<div class="content">
<header>
<h3><?php the_title() ?></h3>
</header>
<div class="image fit">
<img src="<?php bloginfo(\'template_url\')?>/style/images/pic01.jpg" alt="" />
</div>
<p><?php the_excerpt(); ?></p>
</div>
</article>
<?php } ?>
</div>
</section>