Author box

This topic is: not resolved

This topic contains 3 replies, has 3 voices, and was last updated by  Gary Jones 1 year, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3584

    tommeyboy
    Participant
    Post count: 3

    I’m running the magazine theme and want to customize the author box a bit.  I have tried using this code in functions.php, but it’s causing the box to display multiple times.  Any idea how to fix?

    /** Add Custom Author Box **/

    //add_action(‘genesis_after_post_content’, ‘custom_author_box’);
    //
    // function custom_author_box() {
    // if ( get_post_type() == “post” && is_single() && ! ( is_category() || is_tag() ) ) {
    // echo ‘<div class=”author-box”>’
    // . get_avatar( get_the_author_id() , 100 )
    // . ‘<h2>’ . ‘<a href=”‘ . get_author_posts_url(get_the_author_meta( ‘ID’ )) . ‘”>’ . get_the_author() . ‘</a>’ . ‘</h2>’
    // . ‘<p>’ . get_the_author_meta( ‘description’, $userID ) . ‘</p>’
    // . ‘<div class=”author-box-links”>’ . ‘<a class=”author-archive-link” href=”‘ . get_author_posts_url(get_the_author_meta( ‘ID’ )) . ‘”>’ . ‘View all posts from ‘ . get_the_author() . ‘</a>’
    // . ‘</div>’
    // . ‘</div>’;
    // }
    // }
    //
    //add_action(‘genesis_before_post’, ‘custom_author_box_archive’);
    //
    // function custom_author_box_archive() {
    // if ( is_author && is_archive() && ! ( is_category() || is_tag() ) ) {
    // echo ‘<div class=”author-box”>’
    // . get_avatar( get_the_author_id() , 100 )
    // . ‘<h2>’ . get_the_author() . ‘</h2>’
    // . ‘<p>’ . get_the_author_meta( ‘description’, $userID ) . ‘</p>’
    // . ‘<div class=”author-box-links”>’
    // . ‘<a class=”author-archive-link” href=”‘ . get_author_posts_url(get_the_author_meta( ‘ID’ )) . ‘”>’ . ‘View all posts from ‘ . get_the_author() . ‘</a>’
    // . ‘</div>’
    // . ‘</div>’;
    // }
    // }

     

     

     

    #11482

    ramseyp
    Participant
    Post count: 99

    Hi there,

    On single posts, are you seeing the author box appear multiple times? On my test, it works correctly on single posts. The code you have in the function custom_author_box_archive() looks problematic. Your conditional is too complicated. Are you wanting it to work only on author archives? If so, why not use:

    if ( is_author() ) { … }

    That would restrict the author box to appear only on author archives. Now, if you want it to appear only once, at the top of the page, you’ll need to modify the function a bit, as that’s outside The Loop. You can try some code I have on this Gist: https://gist.github.com/4519891

    Does this help?

    Cheers!

    Pat


    #11484

    tommeyboy
    Participant
    Post count: 3

    Thank you for the response.   I wanted the author box to show on single posts, archives, and everywhere else that the default wp press setup shows them.

     

    I was hoping to move the author box just above where the tags display on the single post and archive pages.

     

     

    #11664

    Gary Jones
    Moderator
    Post count: 693

    You’ve got an

    is_author

    in there instead of an

    is_author()

    and this may be coming up as true, so always showing the box via the second function.

     

    I also think that:

    if ( get_post_type() == “post” && is_single() && ! ( is_category() || is_tag() ) )

    could be simplified to:

    if ( is_singular( ‘post’ ) )


    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1, 2.1.1 and 2.1.2 (all 90 of them!) | @GaryJ

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.