如何在 wordpress 中为主页创建 Feed 部分

How to create Feed section in wordpress for homepage

我正在尝试做的是,当用户 post 来自他帐户的东西将直接需要显示在 wordpress 网站的主页上。这将适用于所有用户的角色。 在这里,我想建立一个像 LinkedIn 这样的提要页面。 提前致谢。

我假设你有一些知识...... 您可以通过获取用户 ID 来添加一个仅限于特定作者的循环……或用户。你可以这样做:

<!-- Start page loop here -->
<?php
// 'post_type' => 'any' ... to display all post and custom post type related to the author or user
// You should restrict the number of post, you don't want your site crashing by loading all posts available
// I'm letting your imagination take over
$authID = get_the_author_meta( 'ID' );
$query = new wp_query( array( 'author' => $authID,'post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => '3' ) );  if ( $query->have_posts() ): ?>
<h4>Discover your feed </h4>
<?php 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; else: ?>
<h4>Your feed is empty </h4>
<?php endif; ?>
<!-- End page loop here -->

刚刚测试应该可以工作。

问候。 Whosebug、万维网支持 x)