简体   繁体   中英

wordpress - add author picture on top of the post image

I am working in a custom theme in wordpress. One of the pages "solutions_page", displays all the post with category "solutions", with it featured image, the title and some text.

On top of the featured image, I need to add a circle with a picture of the author.

Here is my problem, I don't know where or how to do it. I was thinking I should put a div position absolute to the featured image, and then make it circle. But how can I do it if I do not have the featured image in code?

Here is my single.php, which it is not doing the job as I do not see my div for the picture:

<?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();

So authorCircle is the div I want to see in the content of the post with category "solutions".

Any ideas how can I do it? Should I put the div inside the_content()?

Thank you in advance!!

Please use this code it will display author avatar at your code.

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

In above code respectivly you want get author id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM