• im trying to get the author of a post’s avator image clickable, with the website link as the link. this will be in the sidebar

    the user url works but the avatar doesnt display, it just displays a broken picture link image

    <a href="<?php the_author_meta( 'user_url' ); ?>"><img class="alignnone" title="<?php the_author_meta( 'display_name' ); ?>’s Website" alt="Author Webite Link" src="<?php echo get_avatar( get_the_author_meta('ID'), 32 ); ?>"> </a>

    any advice would help

Viewing 14 replies - 1 through 14 (of 14 total)
  • Might be typo in the get_avatar() function.

    <a href="<?php the_author_meta( 'user_url' ); ?>">
    <img class="alignnone" title="<?php the_author_meta( 'display_name' ); ?>’s Website" alt="Author Webite Link" src="<?php echo get_avatar( get_the_author_meta('ID',32) ); ?>">
    </a>

    With 32 being the id of the current author.

    Thread Starter posthawk

    (@posthawk)

    32 is the size of the image, changing it does work on changing the size of the boken image.

    Just 32 can never be a valid image size as far as I know.

    Maybe array(32,32)

    Thread Starter posthawk

    (@posthawk)

    it assumes square, if i insert just

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

    i do get the image just fine so i know it works

    Ok, I actually went and looked at get_avatar(). It returns a complete image tag, not just the src.

    <a href="<?php the_author_meta( 'user_url' ); ?>"><?php echo get_avatar( get_the_author_meta('ID',32) ); ?></a>
    Thread Starter posthawk

    (@posthawk)

    thanks for that format, but this code is what works on my site

    <a href="<?php the_author_meta( 'user_url' ); ?>"><?php echo get_avatar( get_the_author_meta('ID'), 32); ?></a>

    i havent tried yet to center or ad title, ill let you know how that works

    Thread Starter posthawk

    (@posthawk)

    is there a way to center it and add a tittle? i’ve tried a few different ways and am now quite sure, like do i center the whole thing or just the image?

    Thread Starter posthawk

    (@posthawk)

    well i got it to align right with this code

    <a class="alignright" title="<?php the_author_meta( 'display_name' ); ?>’s Website" alt="Author Webite Link"<a href="<?php the_author_meta( 'user_url' ); ?>"><?php echo get_avatar( get_the_author_meta('ID'), 150); ?></a></a>

    but it wont center, even with class=”aligncenter”

    big problem here!!
    so I messed with the code and I shouldn’t have and now it’s messes up. Please help.
    it’s Page Template page.php
    this is the error i get from those non-working pages

    Parse error: syntax error, unexpected T_ENDIF in /homepages/42/d444256732/htdocs/wp-content/themes/sight/page.php on line 14

    and this is all the code from that page
    Please help.
    super grateful in advance!

    <?php get_header(); ?>

    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>

    <div class=”entry”>
    <div <?php post_class(‘single clear’); ?> id=”post_<?php the_ID(); ?>”>
    <div class=”post-meta”>
    <h1><?php the_title(); ?></h1>
    by <span class=”post-author”>” title=”Posts by <?php the_author(); ?>”><?php the_author(); ?></span> on <span
    class=”post-date”><?php the_time(__(‘M j, Y’)) ?></span> • <span><?php the_time() ?></span> <?php edit_post_link( __( ‘Edit entry’), ‘• ‘); ?>
    <?php if ( comments_open() ) : ?>
    <?php comments_number(__(‘No Comments’), __(‘1 Comment’), __(‘% Comments’), ”, __(‘Comments Closed’) ); ?>
    <? php endif; ?>
    </div>
    <div class=”post-content”><?php the_content(); ?></div>
    <div class=”post-footer”><?php the_tags(__(‘Tags: ‘), ‘, ‘); ?></div>
    </div>
    </div>

    <?php endwhile; ?>
    <?php endif; ?>

    <?php get_footer(); ?>

    Thread Starter posthawk

    (@posthawk)

    dont know why you posted that here.

    `<?php comments_number(__(‘No Comments’), __(‘1 Comment’), __(‘% Comments’), ”, __(‘Comments Closed’) ); ?>
    <strong><? php endif; ?></strong>`

    that end if has something wrong with it, or it shouldnt be there

    i think i just realized im not supposed to be here but post my own issue.. sorry to barge in. first time in support here. I apologize.

    Thread Starter posthawk

    (@posthawk)

    i assume it’s because there is no else

    thank you. i fixed it 🙂

    Thread Starter posthawk

    (@posthawk)

    yep, next time just add a new topic at the top of the previous screen

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Php code isn't working’ is closed to new replies.