我想在前端显示多个作者的姓名,如下所示
约翰·多伊(John Doe),林恩·多伊(Linn Doe)和潘妮(Penny)
在后端我可以为同一篇文章添加许多用户,但在前端只有该帖子的第一位作者同时显示署名和简历。我正在使用二十三个十三主题,以及如何在前端显示添加在后端的所有用户?
这是我的single.php文件
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php twentythirteen_post_nav(); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
其他解决方案:
为了添加添加Co-Authors Plus支持,您必须有权编辑主题模板。为了在前面显示有关多个作者的信息,您需要将必要的Co-Authors Plus模板标签添加到single.php和其他主题文件中。
特别是对于下划线,您需要在显示类似以下内容的地方进行替换:
<?php the_author(); ?>
用这样的东西:
<?php if ( function_exists( 'coauthors' ) ) { coauthors(); } else { the_author(); } ?>
当未激活Co-Authors Plus时,该特定代码段将使您的主题降级。
要向作者显示其帖子链接,您需要使用类似以下内容的内容:
<?php if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else { the_author_posts_link(); } ?>
您可以将以下代码用于BIOS
<?php $coauthors = get_coauthors(); ?>
<?php foreach( $coauthors as $coauthor ): ?>
<center><div class="authbio">
<img src="<?php bloginfo('template_url'); ?>/images/<?php echo $coauthor->user_firstname; ?>.jpg" alt="" class="alignleft"/>
<?php $userdata = get_userdata( $coauthor->ID ); ?>
<?php if ( $userdata->user_description ) echo $userdata->user_description; ?>
</div></center>
<?php endforeach; ?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句