我正在尝试实现 Co-Authors Plus插入。它说您需要更改主题中的一些 PHP。它概述了此 Link 的变化.
我相信我已经找到了我需要在我的主题中更改它的地方。在名为“post-author-info.php”的文件中。
这是它的样子:
<?php
/**
* Post Author Info
*
* @package WP Journal
* @subpackage Include
*/
?>
<div id="authorinfo" class="columns alpha omega marT30 marB20">
<a href="<?php the_author_meta('url'); ?>"><?php echo get_avatar( get_the_author_meta('email'), '80' ); ?></a>
<h5 class="marB10"><?php _e('By', 'contempo'); ?>: <a href="<?php the_author_meta('url'); ?>"><?php the_author(); ?></a></h5>
<p><?php the_author_meta('description'); ?></p>
<div class="clear"></div>
</div>
只需添加这一行 <?php if ( function_exists( 'coauthors' ) ) { coauthors(); } else { the_author(); } ?>
似乎给了我想要的东西。同时显示“Admin”和“Andrew Gable”。
这是应用更改后的屏幕截图。
我不确定如何让它正确链接,以及如何处理照片和多个 Bio。
谢谢
最佳答案
您可能想在 https://wordpress.stackexchange.com/ 上发布此问题
我遇到了类似的问题,并以这种方式解决了:
global $post;
$author_id=$post->post_author;
foreach( get_coauthors() as $coauthor ): ?>
<div class="entry-author co-author">
<?php echo get_avatar( $coauthor->user_email, '96' ); ?>
<h3 class="author vcard"><span class="fn"><a href="<?php echo get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); ?>"><?php echo $coauthor->display_name; ?></a></span></h3>
<p class="author-bio"><?php echo $coauthor->description; ?></p>
<div class="clear"></div>
</div><!-- .entry-author co-author -->
<?php endforeach;
一定要使用 global $post;
和 foreach
循环。
此功能将显示一个作者框,其中包含作者图像/头像、作者姓名及其存档链接以及作者简介。不过,您可能想要使用自己主题的 CSS 类。
关于php - 编辑主题以应用 Co-Authors Plus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15119535/