Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 469 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wordpress - Get author image

#1
<?php while ( have_posts() ) : the_post(); ?>
<section class="panel panel-white">
<div class="row single-post-content">
<?php if ($category_name !== 'Jobs') { ?>
<h5 class="author-post__title"><?php the_author() ?></h5>
<p><?php echo get_the_date(); ?></p>
<?php }

the_content();

if ($category_name !== 'Jobs') { ?>
<div class="row author-post">
<div class="small-12 medium-4 column">
<img src="<?php echo get_avatar(); ?>" alt="" />
</div>
<div class="small-12 medium-8 column">
<h5 class="author-post__title"><?php the_author() ?></h5>
<p>
Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a
galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s
with the release of Letraset sheets containing.
</p>
</div>
</div>
<?php } ?>
</div>
</section>
<?php endwhile;?>


I am trying to pull through the avatar of the author that has written the post.
I thought that <?php echo get_avatar(); ?> would make this work but it doesn't seem to output the right url and gives me a 404 on the image.

What methods have other people done to pull through the avatar image?

I'm looking for an answer that tells me how to do that and if there isn't an image to not show one.


UPDATE:

I have tried to make this work using the below code: I should mention that I am trying to make this work on my local machine as well.

echo get_avatar($authorId, 100);

(the variable uses `get_the_author_id()`)
Reply

#2
<?php echo get_avatar( $id_or_email, $size, $default, $alt, $args ); ?>
where `id_or_email ` is required. This is missing in your code. For more

[To see links please register here]


So in your code, try to get author image:

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

#3
You'll need to add a parameter for "id_or_email" to fetch the appropriate avatar. For WordPress 2.7 or lower, you can use get_the_author_id(). For
WordPress 2.8 and up, you can use get_the_author_meta('ID'). The function returns either a string or false boolean. You can compare the returned value to determine if you have any avatar or not. - [get_avatar][1]

<?php while(have_posts()): ?>
<?php the_post(); ?>
<section class="panel panel-white">
<div class="row single-post-content">
<?php if($category_name !== 'Jobs'): ?>
<h5 class="author-post__title">
<?php the_author() ?>
</h5>
<p><?php echo get_the_date(); ?></p>

<?php the_content(); ?>

<div class="row author-post">
<div class="small-12 medium-4 column">
<?php if($avatar = get_avatar(get_the_author_meta('ID')) !== FALSE): ?>
<img src="<?php echo $avatar; ?>" alt="">
<?php else: ?>
<img src="/images/no-image-default.jpg">
<?php endif; ?>
</div>
<div class="small-12 medium-8 column">
<h5 class="author-post__title"><?php the_author() ?></h5>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing.</p>
</div>
</div>
<?php else: ?>
<?php the_content(); ?>
<?php endif; ?>
</div>
</section>
<?php endwhile; ?>



[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through