![](/img/trans.png)
[英]Is it possible to have a wordpress installation with homepage and all pages on the root, but the posts on a subdir?
[英]Is it possible to view posts and pages on the homepage of a wordpress blog?
你可以循環它。
只需為帖子做一個循環:
<!-- Start post loop here -->
<?php $query = new wp_query( array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => '3' ) ); ?>
<?php if ( $query->have_posts() ): while ( $query->have_posts() ): $query->the_post(); ?>
<!-- Start post template here -->
<div><a aria-label="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<!-- End post template here -->
<?php endwhile; endif; ?>
<!-- End post loop here -->
頁面循環:
<!-- Start page loop here -->
<?php $query = new wp_query( array( 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => '3' ) ); ?>
<?php if ( $query->have_posts() ): while ( $query->have_posts() ): $query->the_post(); ?>
<!-- Start page template here -->
<div><a aria-label="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<!-- End page template here -->
<?php endwhile; endif; ?>
<!-- End page loop here -->
冰川
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.