Community Forums › Forums › Archived Forums › Design Tips and Tricks › Author box
Tagged: archive, authorbox author box
- This topic has 3 replies, 3 voices, and was last updated 11 years, 3 months ago by Gary Jones.
-
AuthorPosts
-
December 6, 2012 at 10:09 am #3584tommeyboyMember
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>';
// }
// }January 12, 2013 at 12:53 pm #11482ramseypMemberHi 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
January 12, 2013 at 1:48 pm #11484tommeyboyMemberThank 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.
January 13, 2013 at 3:47 pm #11664Gary JonesMemberYou'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' ) )
WordPress Engineer, and key contributor the Genesis Framework | @GaryJ
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.