设置页面分为不同的选项卡,默认情况下将位于“常规”选项卡上。您可以查看选项并更改它宁波网页优化们以符合您的要求。
在此页面上,您需要向下滚动到底部并选择“匹配当前帖子的作者”选项旁边的“是”。您可以取消选中其他匹配选项,以确保插件仅按作者提取帖子。
接下来,您需要切换到“展示位置”标签并激活“发布后输出”选项。您还可以宁波网页优化通过编辑“参数”框中的文本来编辑输出模板。
不要忘记点击“保存设置”按钮来存储您的更改。
您现在可以访问您网站上的任何一篇帖子,并且您会在帖子内容后看到同一作者的相关帖子。
|
1
2
3
4
五
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 |
function wpb_related_author_posts($content) {if ( is_single() ) { global $authordata, $post; $content .= '<h4>Similar Posts by The Author:</h4> '; $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) ); $content .= '<ul>'; foreach ( $authors_posts as $authors_post ) { $content .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>'; } $content .= '</ul>'; return $content; } else { return $content; }}add_filter('the_content','wpb_related_author_posts'); |
我们希望本文能帮助您学习如何在WordPress中轻松显示同一作者的相关帖子。您可能还希望看到我们为初学者提供最受欢迎的WordPress提示,技巧和黑客的最终列表。