wordpress - 是否可以在 wordpress 博客的主页上查看帖子和页面?
解决方案
你可以循环它。
只需为帖子做一个循环:
<!-- 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 -->
冰川
推荐阅读
- c# - 如何解决 Connection is closed-OleDBConnection 错误
- android - rxjava - 不按顺序发出的项目
- java - Java Spring:如何将maven依赖声明为gradle
- html - Angular8 PrimeNG 多选禁用属性不起作用
- reactjs - 如何在 Material UI 中自动调整 AutoComplete 字段的大小?
- javascript - 使用 CSS 和 JS 的 HTML 可折叠表格部分
- javascript - VSCode 调试断点 - nodejs
- python - 有没有办法使用 Python 从 XLSX 文件中获取长公式的计算值
- c - 在linux中用c打印几次
- asp.net - 我如何解析 XML 字符串并检索特定节点?