Home > Enterprise >  Wordpress - rearrange post title, date, featured image and author
Wordpress - rearrange post title, date, featured image and author

Time:06-24

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 >
  <div ><?php echo get_the_date() ?></div>
  <div ><?php echo get_the_title() ?></div>
  <div >written by <span ><?php echo get_the_author() ?></span></div>
  <div >
    <img src="<?php the_post_thumbnail(); ?>">
  </div>
</div>

CodePudding user response:

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 to all this help!

CodePudding user response:

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

<div  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

  • Related