简体   繁体   English

是否可以在 wordpress 博客的主页上查看帖子和页面?

[英]Is it possible to view posts and pages on the homepage of a wordpress blog?

Currently, On my blog homepage, only posts are visible.目前,在我的博客主页上,只有帖子可见。 But I want to view both the posts and pages on the same homepage as shown in the image below.但我想在同一个主页上查看帖子和页面,如下图所示。

在此处输入图像描述

How is it possible to achieve this?怎么可能做到这一点?

you can loop it.你可以循环它。

Just do a loop for 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 -->

And a loop for pages:页面循环:

<!-- 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 -->

gl.冰川

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在主页上将所有页面都放在根目录上,而将子目录中的帖子放在worddir下进行wordpress安装? - Is it possible to have a wordpress installation with homepage and all pages on the root, but the posts on a subdir? 在(WordPress)主页的2列中显示2个最新博客文章 - Show 2 Recent Blog Posts in 2 Columns on Homepage in (WordPress) Wordpress中的所有页面和帖子都重定向到主页 - All pages and posts in Wordpress redirect to homepage 将所有 WordPress 帖子和页面重定向到主页 - Redirect all WordPress posts and pages to homepage Wordpress类别页面显示所有博客帖子 - Wordpress Category Pages Showing All Blog Posts Wordpress-单独的博客页面,不显示帖子,而是显示自定义主题的首页 - Wordpress - separate blog page not showing the posts but showing the homepage of the custom theme Nginx Wordpress无法访问博客文章,但可以访问主页 - Nginx Wordpress can't access blog posts but homepage accessible 是否可以在 Wordpress 博客页面中显示即将发布的帖子? - Is it possible to display upcoming posts in Wordpress blog page? wordpress博客首页自定义 - wordpress blog homepage customization Wordpress最近发布的帖子未显示在首页上,而是显示在其他页面上 - Wordpress recent posts not showing on homepage, but shows up on other pages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM