簡體   English   中英

wordpress-在帖子圖像頂部添加作者圖片

[英]wordpress - add author picture on top of the post image

我正在使用wordpress中的自定義主題。 頁面“ solutions_page”之一顯示所有類別為“ solutions”的帖子,並帶有特色圖片,標題和一些文本。

在精選圖片的頂部,我需要添加一個帶有作者照片的圓圈。

這是我的問題,我不知道在哪里或怎么做。 我當時想我應該將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()嗎?

先感謝您!!

請使用此代碼,它將在您的代碼上顯示作者頭像。

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

分別在上述代碼中,您想要獲得作者ID。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM