最新活动:买一送一!升级会员,最高返 500 抵扣券!>>>

如何显示相同的作者在WordPress的相关文章

你想在WordPress中显示相同作者的相关文章吗? 通常,您可以使用任何相关的文章插件在您的网站上显示类似的文章。 但是,如果您的WordPress网站有多个作者,则用户可能需要阅读同一作者的其他内容。 在本文中,我们将向您展示如何在WordPress中显示相同作者的相关文章。此方法要求您将代码添加到WordPres...

你想在WordPress中显示相同作者的相关文章吗? 通常,您可以使用任何相关的文章插件在您的网站上显示类似的文章。 但是,如果您的WordPress网站有多个作者,则用户可能需要阅读同一作者的其他内容。 在本文中,我们将向您展示如何在WordPress中显示相同作者的相关文章。

此方法要求您将代码添加到WordPress主题文件中。 您需要将以下代码添加到主题的functions.php文件或特定于站点的插件中。

function ie_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="'%20.%20get_permalink(%20$authors_post->ID%20)%20.%20'">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';    }    $content .= '</ul>';      return $content;    }     else {     return $content;     }} add_filter('the_content','ie_related_author_posts');
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
wordpress教程

写文案 一定要有“视觉感”

2023-2-16 15:50:42

wordpress教程

WordPress 不同页面对应不同模板解决方法

2023-2-16 15:50:45

!
你也想出现在这里?立即 联系我们吧!
信息
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
搜索