• Hi all,

    At wits end trying to get this going after upgrading to 4.4.

    Had it working flawlessly with previous versions.

    So all I am trying to do is get the author’s avatar to display to the left of the post when listing posts on the main page.

    I am using WP User Avatar to save the photos against each author.

    Within the loop in index.php I have:

    echo get_avatar( get_the_author_meta( ‘ID’ ), 96 );

    Adding the above line to single.php works.

    However no matter what I have tried I cant get it to work within the loop.

    I have gone as far as deleting everything in index.php and have not had an issue with the main page loading and displaying posts. Does 4.4 even reference index.php anymore?

    My apologies if this has been documented but I am not seeing this referenced anywhere.

    I have changed themes and tested with the same result across al themes used including twentyfifteen.

    Any help to resolve this issue would be greatly appreciated.

    The website is https://www.clubpunter.com.au

    Thanks

    Dan

Viewing 4 replies - 1 through 4 (of 4 total)
  • Had it working flawlessly with previous versions.

    What was the code you used? The one you posted?

    Try this…
    echo get_avatar(get_the_author_meta( 'ID', $post->post_author ), 96);
    …or shortened…
    echo get_avatar( $post->post_author, 96);
    …from here: How can I display other user avatars on an author profile page?.

    Thread Starter plantagenet

    (@plantagenet)

    He NeoTechnomad,

    Thank you for your suggestion. Same thing however, no avatars are displayed on the main page.

    index.php

    <?php
    get_header();
    $isPaged = is_paged();
    $blogfp = true;
    $first = true;
    $lastThumb = ”;

    if (empty($pageTemplate) && !$isPaged) blogFrontpageAd();

    if (have_posts()) :
    while (have_posts()) : the_post();

    echo get_avatar( $post->post_author, 96);

    // Get post type
    if ($first && !$isPaged && in_array(‘Feature Image’, $bf_features) && !in_array(‘featureFrontpage’, $bf_misc)) $postType = “feature”;
    elseif ( (!$first || $isPaged) && in_array(‘Thumbnails’, $bf_thumb)) $postType = “thumb”;
    else $postType = “normal”;
    $postType = apply_filters(‘bf_post_layout’, $postType);

    if ( !empty( $first ) ) {
    // if feature image
    if ($postType == “feature”) bf_featured(); ?>

    <?php bf_before_content(); ?>
    <!– begin #content –>
    <div id=”content”>
    <?php } if(!$first && $postType == “normal”) echo ‘<div class=”postdivider”></div>’;
    ?> <!– begin post –>
    <article id=”post-<?php the_ID(); ?>” class=”post frontpage <?php echo $postType;?> <?php echo $lastThumb;?> <?php bigfeature_post_class(); ?>”> <?php
    if ( $postType == “normal” || $postType == “thumb”) {
    if ( in_array(‘imageBelowTitle’, $bf_misc) && $postType !== “thumb”) add_action( ‘bf_content_feature_below_title’, ‘bf_content_below_title_featured_area’ );
    else bf_content_feature();
    }

    if($postType == “thumb”) { ?>
    <div class=”thumbcontent”><h2>” rel=”bookmark” title=”<?php printf(__ (‘Permanent Link to %s’, ‘BigFeature’), get_the_title())?>” class=”thumb-link”><?php the_title(); ?></h2> <?php meta($postType); bf_excerpts(false,$bf_thumbnail_numwords,$postType); ?></div>

    <?php } else { ?>
    <div class=”post-title cufonheading”><h2>” rel=”bookmark” title=”<?php printf(__ (‘Permanent Link to %s’, ‘BigFeature’), get_the_title())?>”><?php the_title(); ?></h2><?php if (comments_open() && in_array(‘Comment Icon’, $bf_meta)) { ?><div class=”comment”><?php comments_popup_link(‘0’, ‘1’, ‘%’); ?></div><?php } echo ‘</div>’; ?>

    <?php bf_before_post_content(); ?>
    <?php bf_content_feature_below_title(); ?>
    <?php bf_excerpts(false, $bf_normalpost_numwords, $postType); ?>
    <?php bf_after_post_content(); ?>
    <?php bf_below_posts(); ?>
    <?php } ?>

    </article>
    <!– end post –>
    <?php if ( !empty( $first ) ) { $first = false; if (bf_get_option(‘bf_cufon’)) echo ‘<script type=”text/javascript”> Cufon.refresh(); </script>’; }
    if ($postType == “thumb”) if ($lastThumb == “last-thumb”) { $lastThumb=”; echo ‘<div class=”clear”></div>’; } else $lastThumb = “last-thumb”; ?>
    <?php endwhile; ?>
    <div class=”clear”></div>
    <?php bf_pagenavigation($bf_blog_navigation_style); ?>
    <?php else : ?>
    <div id=”content”><p><?php _e(‘No Posts Found’,’BigFeature’); ?></p>
    <?php endif; ?>
    <div class=”clear”></div>
    </div>
    <!– end #content –>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I have tried echo get_avatar( $post->post_author, 96); in single.php which works.

    Why is it that should I delete all the code in index.php it has no affect on the main page. I could basically fill index.php with garbage and the site will work.

    this leads me to think that index.php is not referenced at all after upgrading to 4.4.2

    Thanks

    As this is not a standard loop, but a series if “if” statements, it would have to somewhere after “<!– begin post –>”.
    I placed inside one of the wp_query loops on my site and the avatar of the author showed up.

    Thread Starter plantagenet

    (@plantagenet)

    Thanks for the reply.

    Where would one of the wp_query loops start?

    I have tried populating echo get_avatar( $post->post_author, 96); throughout the if statements to see if at least I get something on author avatars on the main page but I am still not having any luck.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_avatar within "The Loop" not working’ is closed to new replies.