0

So I have this website that I am building and I am using get_the_author_meta to display various information about the user / author including user image.

I added a function in my functions.php which allows to add more options to the author profile such as: facebook profile, twitter, image etc etc..

this is the basic function which display the value in the theme files:

<?php echo esc_attr( get_the_author_meta( 'slider_pic', $user->ID ) ); ?>

Now - it works fine throughout the whole site and all templates: single.php, page.php etc etc but in my homepage (in my case index.php) there is a problem:

I included a slider which contains the images of the authors + link to their respective profile pages and beneath that slider I am showing the 9 latest blog posts of the site and next to the name of the author should be the image using the code above.

for some reason the slider preventing the images to display in the 9 boxes. when I use this code:

<?php echo esc_attr( get_the_author_meta( 'slider_pic', $user->ID ) ); ?>

in the slider it works fine but beneath that in the another loop the image dont appear at all. when I remove the include that calls the slider the images in the 9 boxes show....

This is the code Im using for the slider: https://dl.dropbox.com/u/4405634/slider.php

and this is the code I am using for the homepage which include the slider in it: https://dl.dropbox.com/u/4405634/index.php

I am assuming it is either a conflict or something that has to do with loops or whatever

would love to have a solution

Thanks, Gil

  • Clicking those links trigger a file download. Please paste code to a pastebin such as pastebin.com so it can be viewed directly. – s_ha_dum Dec 27 '12 at 23:13
2

In the "homepage" code you posted, you have get_the_author_meta commented out.

<?php /*?><img src="<?php echo esc_attr( get_the_author_meta( 'author_pic_sidebar', $user->ID ) ); ?>" alt="" /><?php */?>

That is why it doesn't work. See that <php /*?> right at the beginning of the line?

0

it was my mistake to comment this code, in my real code it is not. anyway I found a solution myself finally. changing the variable $user->ID to $author fixed the problem that's the working code:

<img src="<?php echo esc_attr( get_the_author_meta( 'author_pic_sidebar', $author ) ); ?>" alt="" class="author-avatar" />

hope it helps. thanks for the answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.