Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using advanced custom fields and have setup an image field for my users to add an image in their profile. I'd need to display this image on post pages, so i've tried the following...

<?php
$attachment_id = the_author_meta('author_logo');
?>
<?php echo the_author_meta('author_logo'); ?>
<?php wp_get_attachment_image_src( $attachment_id )?> 
<?php wp_get_attachment_url( $attachment_id ); ?>

The output is always the image attachment ID never the URL. What can I change to output the image path URL?

Thanks

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

From codex:

The the_author_meta Template Tag displays the desired meta data for a user. If this tag is used within The Loop, the user ID value need not be specified, and the displayed data is that of the current post author. A user ID can be specified if this tag is used outside The Loop.

If the meta field does not exist, nothing is printed.

NOTE: Use get_the_author_meta() if you need to return (not display) the information.

So, replace the_author_meta() with get_the_author_meta(). You can then use wp_get_attachment_image() to get an image element ready for outputting to the page.

<?php 
$id = get_the_author_meta('author_logo');
if ($id) {
    echo wp_get_attachment_image($id);
}
?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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