Support » Fixing WordPress » Profile pic on pages not posts

  • Resolved giveabrick

    (@giveabrick)


    Hi,
    I need some help adjusting the code so that a profile pic shows up in posts but not on pages. Right now I have <?php echo get_avatar( get_the_author_email(), ’50’ ); ?> in the loop but that has resulted in authors images being on both post and pages.

    Is there somewhere else I should put this so that only posts get pics? Or is there something else I should do in a different place to override this instruction on pages?

    Many thanks for your help,
    Eleanor

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try:

    <?php if(is_page()) echo get_avatar( get_the_author_email(), '50' ); ?>

    Thread Starter giveabrick

    (@giveabrick)

    Hi Esmi,
    Thanks for your help but that shows pic on page and not posts whereas I’d like it the other way round (pic showing on posts, not pages)

    I tried changing what you gave me to:

    <?php if(is_post()) echo get_avatar( get_the_author_email(), ’50’ ); ?>

    and then ..
    <?php if(is_not_page()) echo get_avatar( get_the_author_email(), ’50’ ); ?>

    followed by ..
    <?php if(is_post()) echo get_avatar( get_the_author_email(), ’50’ ); ?>

    and …
    <?php if(have_post()) echo get_avatar( get_the_author_email(), ’50’ ); ?>

    but all gave errors saying:
    Fatal error: Call to undefined function is_post() in /home/custard/public_html/giveabrick/wp-content/themes/atahualpa/index.php on line 14

    So next question I guess is what function do I need instead of ‘is_page to get the pic showing on posts not pages?

    Many thanks for your help and patience,
    Eleanor

    Thread Starter giveabrick

    (@giveabrick)

    Hi,
    I wasn’t sure where to put that (sorry, I’m brand new to this) but your link to the conditional tags page was brilliant because I’ve found this to work:

    <?php if(is_home()) echo get_avatar( get_the_author_email(), ’50’ ); ?>
    <?php if(is_single()) echo get_avatar( get_the_author_email(), ’50’ ); ?>

    Without that page you showed me, I would never have known what to put for a post and using the (is_home) allows author pics to show on main page as well as single post pages.

    Someone cleverer than me will have a neater way to do this but I’m just delighted because it’s doing what I want it to so thank you ever so much for helping me.
    Eleanor

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Profile pic on pages not posts’ is closed to new replies.