简体   繁体   中英

Wordpress - rearrange post title, date, featured image and author

I'm editing single post (single.php) in Wordpress in order to rearrange where I want to show blog title , author , date and featured image .

So far I've managed to pull date and title and featured image , but not author .

Can somebody help me out, what is the correct function to call author ? I was also wondering if it's possible to put featured image as background image on the .blog-info element, I don't know if I can pull just the source image?

This is where I'm at so far:

<div class="blog-info">
  <div class="blog-date"><?php echo get_the_date() ?></div>
  <div class="blog-title"><?php echo get_the_title() ?></div>
  <div class="blog-author">written by <span class="blog-author-name"><?php echo get_the_author() ?></span></div>
  <div class="blog-image">
    <img src="<?php the_post_thumbnail(); ?>">
  </div>
</div>

I've managed to solve it by adding:

<?php $post = get_post(); ?>
<?php setup_postdata($post); ?>
<?php echo get_the_author(); ?

Thanks to Brad Holmes for all the help!

i will answer your image question as you say you can just pull the image into the div like so

<div class="blog-info" style="background-image: url('<?php the_post_thumbnail(); ?>')"></div>

as we have already fixed your author question in chat but please try not to ask two questions at a time as per rules of StackOverflow

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