0

When author has no posts, it does not display author name or bio (below code). I tried http://codex.wordpress.org/Author_Templates#Custom_Author_Information but it give me Notice: Trying to get property of non-object.

This below code is in archive.php

<?php
    the_archive_title( '<h1 class="page-title">', '</h1>' );
    the_archive_description( '<div class="taxonomy-description">', '</div>' );

    // Show an optional term description.
    $term_description = term_description();

    // Show author bio
    if ( is_author() ):
        get_template_part( 'author-bio' );
    endif;

    if ( ! empty( $term_description ) ) :
        printf( '<div class="taxonomy-description">%s</div>', $term_description );
    endif;
?>

author-bio.php

<div class="article-meta">
    <div class="author-avatar">
        <p>
        <?php
        /**
         * Filter the author bio avatar size.
         *
         * @param int $size The avatar height and width size in pixels.
         */
        $author_bio_avatar_size = apply_filters( 'simtiful_author_bio_avatar_size', 56 );

        echo get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size );
        ?>
        </p>
    </div><!-- .author-avatar -->

    <div class="author-description">
        <h3 class="article-author"><?php echo get_the_author(); ?></h3>

        <p class="author-bio">
            <?php the_author_meta( 'description' ); ?>
            <p>
            <a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
                <?php printf( __( 'View all posts by %s', 'simtiful' ), get_the_author() ); ?>
            </a>
            </p>
        </p><!-- .author-bio -->

    </div><!-- .author-description -->
</div><!-- .author-info -->
2
  • Post the code from author-bio.php Commented Sep 20, 2015 at 5:42
  • so where is the error, what exactly you get in addition to the error? Commented Sep 20, 2015 at 9:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.