目前,在我的博客主页上,只能看到帖子。但我想在同一个主页上同时查看帖子和页面,如下图所示。

怎么可能做到这一点呢?
发布于 2020-06-21 06:36:31
你可以循环它。
只需为posts执行一次循环:
<!-- 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 -->总帐
https://stackoverflow.com/questions/62464493
复制相似问题