gpt4 book ai didi

php - Wordpress - 获取作者图片

转载 作者:行者123 更新时间:2023-12-01 10:32:40 25 4
gpt4 key购买 nike

<?php while ( have_posts() ) : the_post(); ?>
<section class="panel panel-white">
<div class="row single-post-content">
<?php if ($category_name !== 'Jobs') { ?>
<h5 class="author-post__title"><?php the_author() ?></h5>
<p><?php echo get_the_date(); ?></p>
<?php }

the_content();

if ($category_name !== 'Jobs') { ?>
<div class="row author-post">
<div class="small-12 medium-4 column">
<img src="<?php echo get_avatar(); ?>" alt="" />
</div>
<div class="small-12 medium-8 column">
<h5 class="author-post__title"><?php the_author() ?></h5>
<p>
Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a
galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s
with the release of Letraset sheets containing.
</p>
</div>
</div>
<?php } ?>
</div>
</section>
<?php endwhile;?>

我试图通过写这篇文章的作者的头像。
我认为这会使这项工作有效,但它似乎没有输出正确的 url 并在图像上给我一个 404。

其他人用什么方法拉过头像?

我正在寻找一个答案,告诉我如何做到这一点,如果没有不显示的图像。

更新:

我已经尝试使用以下代码来完成这项工作:我应该提到我也在尝试在我的本地机器上进行这项工作。
echo get_avatar($authorId, 100); 

(变量使用 get_the_author_id() )

最佳答案

<?php echo get_avatar( $id_or_email, $size, $default, $alt, $args ); ?> 

哪里 id_or_email是必须的。这在您的代码中缺失。更多 https://codex.wordpress.org/Function_Reference/get_avatar

所以在你的代码中,尝试获取作者图片:
<?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?>

关于php - Wordpress - 获取作者图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40751664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com