【问题标题】:wordpress - add author picture on top of the post imagewordpress - 在帖子图片顶部添加作者图片
【发布时间】:2015-05-14 16:53:05
【问题描述】:

我正在使用 wordpress 中的自定义主题。其中一个页面“solutions_page”显示所有具有“解决方案”类别的帖子,其中包含特色图片、标题和一些文字。

在特色图片的顶部,我需要添加一个带有作者图片的圆圈。

这是我的问题,我不知道在哪里或如何做。我在想我应该把一个绝对的 div 位置放在特色图像上,然后让它变成圆形。但是如果我的代码中没有特色图片怎么办?

这是我的 single.php,它没有做这项工作,因为我看不到图片的 div:

<?php get_header(); ?>

<div class="container">
    <?php
    if (have_posts()) {
        while (have_posts()) {
            the_post();

            if (in_category('solutions')) {
                the_content();
                ?>
              <div class="authorCircle">
                <img src="images/jules.jpg" alt=""/>
              </div>
          <?php
          } else {
              the_content();
          }
      } // end while
  } // end if
  ?>
</div>
  <?php
  get_footer();

所以 authorCircle 是我想在帖子内容中看到的具有“解决方案”类别的 div。

任何想法我该怎么做?我应该把 div 放在 the_content() 里面吗?

提前谢谢你!!

【问题讨论】:

  • 只有特色图片时你想要其他图片吗??
  • 不安静。所以,我想要在特色图片(kuldip Makadiya 告诉我的头像)之上再放一张图片,显示作者的图片。但是因为我通过仪表板设置了特色图片,所以我也不知道在哪里放置代码以放置头像。有意义吗?

标签: php wordpress post


【解决方案1】:

请使用此代码,它将在您的代码中显示作者头像。

<?php echo get_avatar( get_the_author_meta('ID'), 60); ?>

在上面的代码中,您分别想要获取作者 ID。

【讨论】:

  • 你!我不知道你可以为作者放一个头像!!我需要先检查如何设置它们。谢谢!!!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-01
  • 2012-05-29
  • 1970-01-01
相关资源
最近更新 更多