- This topic has 11 replies, 2 voices, and was last updated 3 years, 5 months ago by David.
-
AuthorPosts
-
November 19, 2020 at 3:20 am #1537321Marcel
Hello,
I wonder how it would be possible for the author box to be in the sidebar, something similar to here.
I think this could be done with a PHP code snippet, using a Block Element, right?
Can you give me a suggestion in this regard?
Many thanks!Marcel
November 19, 2020 at 4:00 am #1537354DavidStaffCustomer SupportHi there,
will there be multiple authors or just one ?
November 19, 2020 at 4:04 am #1537359MarcelOne author/ article.
November 19, 2020 at 5:41 am #1537440DavidStaffCustomer SupportSorry what i meant was – will the Site have multiple authors ?
November 19, 2020 at 5:43 am #1537446MarcelMultiple authors.
November 19, 2020 at 6:20 am #1537488DavidStaffCustomer SupportSorry for the extra questions. On your example the author has extra meta data, such as the Position / Email and Phone number. Some of that is not standard meta of the user profile in WP. Are they also required ?
November 19, 2020 at 10:51 am #1537984MarcelIt would be great if those extra meta could be added. Not necessary exactly the same, but as a general idea, YES. Maybe instead of position, to be a website address.
November 20, 2020 at 2:03 am #1538602DavidStaffCustomer SupportSo for the meta you’re limited to the User profile meta:
https://developer.wordpress.org/reference/functions/get_the_author_meta/
This code for example provides: avatar, static label, author name ( with link ), description, email and website:
<div class="author-box"> <div class="avatar"><?php echo get_avatar( get_the_author_meta( 'ID' )); ?></div> <p class="author-label">Author</p> <p class="author-title"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php printf( esc_attr( '%s', 'the author'), get_the_author_meta('display_name') );?></a></p> <p class="author-description"><?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?></p> <p><?php echo get_the_author_meta( 'user_email' ); ?></p> <p><?php echo esc_url( get_the_author_meta( 'url' ), null ); ?></p> </div>
Add this to a new Hook Element and select
generate_before_left_sidebar_content
Check execute PHP, and set the Display Rules to Posts > All Posts.Then a little CSS for styling:
.author-box { text-align: center; padding: 10px; } .author-box p, .author-box a { margin-bottom: 0.25em; font-size: 14px; color: #000; } .author-box .avatar img { border-radius: 50px; margin-bottom: 0.5em; } .author-box .author-title { font-weight: bold; margin: 0.5em 0; }
I added CSS classes to each meta element if you want to tweak them individually.
November 20, 2020 at 2:26 am #1538620MarcelDavid,
This is awesome. Thank you.
One more Q: How could I make the website URL clickable?November 20, 2020 at 3:19 am #1538665DavidStaffCustomer SupportReplace this:
<p><?php echo esc_url( get_the_author_meta( 'url' ), null ); ?></p>
for:
<a href="<?php echo esc_url( get_the_author_meta( 'url' ), null ); ?>"><?php echo esc_url( get_the_author_meta( 'url' ), null ); ?></a>
November 20, 2020 at 3:31 am #1538673MarcelPerfect. Thank you very much!
November 20, 2020 at 3:38 am #1538680DavidStaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.