Forums

[resolved] Adding an author picture (14 posts)

  1. neildubya
    Member
    Posted 4 years ago #

    Hi

    I'm trying to get author pictures to appear next to posts using the method described in the WordPress 2 Visual Quickstart Guide book; that is, placing the following code in my theme's index.php file

    <img src="<?php get_bloginfo('url'); ?>wp-content/images/authors/<?php the_author_ID();?>.jpg" class="auth" alt="<?php the_author(); ?>. " title="<?php the_author(); ?> "/>

    I've created a directory at wp-content/images/authors and uploaded a picture which is named the same as my author ID but the picture is not appearing. Assuming the code is correct (I don't know enough PHP to say for sure) then I guess it must be either a problem with my path or maybe permissions? Or is there something else I haven't thought of?

    Any help appreciated - many thanks.

    Neil

  2. MarkMichon
    Member
    Posted 4 years ago #

    I think you are just missing one little thing:
    Right before wp-content, you want a "/" without the quotes.

    If that doesn't work could you like to it not working?

  3. neildubya
    Member
    Posted 4 years ago #

    Thanks Mark - I thought perhaps that php get_bloginfo('url') would give myblogurl.net/ but maybe it just gives myblogurl.net, in which case the extra "/" should make all the difference. Will try it later to see if it works.

    Not sure what you mean by "could you like to it not working"...?

    Neil

  4. MarkMichon
    Member
    Posted 4 years ago #

    sorry, it's late. I meant "link" not like.

  5. neildubya
    Member
    Posted 4 years ago #

    Me again. Unfortunately the extra "/" hasn't made any difference. Looking at the source of my front page it looks like get_bloginfo() doesn't seem to be doing much as the image source is not the proper path. The URL of my blog is http://fifteensquared.net.

    Once again, any help much appreciated.

    Neil

  6. neildubya
    Member
    Posted 4 years ago #

    Just a quick thought; I've assumed that it shouldn't make any difference which theme I'm using. Is that correct?

    cheers

    Neil

  7. DianeV
    Member
    Posted 4 years ago #

    So long as you've input the code you've specified above in the theme that you're using, then it (theoretically) shouldn't matter.

  8. neildubya
    Member
    Posted 4 years ago #

    That's what I thought. Either way, I can't get that code to work though.

  9. DianeV
    Member
    Posted 4 years ago #

    Okay. Have you tried:

    <img src="<?php get_bloginfo('home'); ?>/wp-content/images/authors/<?php the_author_ID();?>

    Also, are you sure that your image is named correct? Can you access the image directly at the URL via a browser?

  10. neildubya
    Member
    Posted 4 years ago #

    I am a fool. It was a permissions problem - DianeV got it right: I couldn't access the image from a browser.

    Thanks for your help everyone.

    Neil

  11. DianeV
    Member
    Posted 4 years ago #

    > I am a fool. It was a permissions problem

    Well, why should you be different? :)

    We've all, I'm sure, made loads of mistakes along the way.

  12. elistr
    Member
    Posted 4 years ago #

  13. Monarch
    Member
    Posted 4 years ago #

    I have tried the follwoing based on this post.

    <img width="135" height="180" src="<?php get_bloginfo('home'); ?>/wp-content/uploads/authors<?php the_author_ID();?>

    I get a blank box on the author.php page,

    I can get the photos by palceing the link in a web page. I used this link and get the photo:
    http://monarchhousing.org/wordpress/wp-content/uploads/authors/24.JPG

    What am i doing wrong?

  14. Jon Griffith
    Member
    Posted 4 years ago #

    I had a heck of a lot more luck with the following:

    <img src="<?php bloginfo('template_directory'); ?>/images/authors/<?php the_author_ID();?>.jpg" class="auth" alt="<?php the_author(); ?>. " title="<?php the_author(); ?> "/>

Topic Closed

This topic has been closed to new replies.

About this Topic