- This topic has 24 replies, 6 voices, and was last updated 1 year, 5 months ago by
David.
-
AuthorPosts
-
November 15, 2020 at 6:54 am #1532320
Álvaro
Hi!
I have add to my website this hook code, in GeneratePress elements, inspired by one found in this forum:
<div class="author-box"> <div class="avatar"> <?php echo get_avatar( get_the_author_meta('user_email'), '96', '' ); ?> </div> <div class="author-info"> <h5 class="author-title" itemprop="author" itemscope itemtype="http://schema.org/Person"> <span itemprop="name"><?php printf( get_the_author_meta( 'display_name') );?></span> </h5> <div class="author-summary"> <p class="author-description"><?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?></p></div> <div class="author-links"> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>" title="Read more">...</a> </div> </div> </div>
I have some posts that have two or more authors, so I want to show their boxes. Is it possible?
Another thing. Authors in my website have their social media links. Is it possible to show adding some code?
I don’t want to use a plugin, just code in the hook.
Thanks! I’m very excited with Generate Press 🙂
November 15, 2020 at 8:20 am #1532409David
StaffCustomer SupportHi there,
co-authors and social links are not part of WordPress core, adding that functionality would require another plugin or custom function. So unfortunately this kind of function would require custom development or a plugin.
I would recommend looking for a plugin to do this, as code is code whether it be in a plugin or custom developed. The advantage of a plugin is you have developer support that will maintain the code for any updates WP makes.
Simple Author Box provides author social links:
https://en-gb.wordpress.org/plugins/simple-author-box/
It does also provide co-authors as part of their premium plugin.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/November 15, 2020 at 8:56 am #1532442Álvaro
Hi, David.
Thanks. I excepted maybe is possible to add co-authors. I’ve seen in this forum this code from Tom (as I remember):
add_filter( 'generate_post_author_output', 'tu_co_author_plus' ); function tu_co_author_plus( $author ) { if ( function_exists( 'coauthors_posts_links' ) ) { return ' Por ' . coauthors_posts_links( null, null, null, null, false ); } return $author;
It helps to show co-authors names below title. Maybe it’s possible to add this function to the code I provided above.
Thanks!
Edit: the code was yours! 🙂
November 15, 2020 at 9:46 am #1532473Álvaro
November 15, 2020 at 2:02 pm #1532679Tom
Lead DeveloperLead DeveloperHi there,
With co authors plus, you may be able to replace this:
<span itemprop="name"><?php printf( get_the_author_meta( 'display_name') );?></span>
With this:
<?php if ( function_exists( 'coauthors_posts_links' ) ) { echo 'Por ' . coauthors_posts_links( null, null, null, null, false ); } ?>
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 15, 2020 at 2:10 pm #1532683Álvaro
November 16, 2020 at 9:53 am #1533722Tom
Lead DeveloperLead DeveloperAh, you’re wanting to display two completely different author boxes?
In that case, you would need a way to get all authors of the post (a function), then we’d need to loop your original code and replace the internals with the data from the function.
Not sure of co authors plus allows for this?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 16, 2020 at 11:55 am #1533824Álvaro
Hi, Tom. Yes, this is what I had with my previous theme, Herald (by Meks). Their plugin (Meks Smart Author Widget) also allows to show more than one box, but it has a terrible viewing in themes that are not by Meks. Maybe you can see their code, because it’s a thing that is allowed by co-authors plus.
Thanks, Tom. You and you’re team are amazing and good partners!!
November 17, 2020 at 9:16 am #1535018Tom
Lead DeveloperLead DeveloperUnfortunately, I’m not able to dig into other plugin code at the moment.
However, if you’d like to set it up on your site, we can see if we can make it display nicer with some CSS.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 17, 2020 at 9:43 am #1535059Álvaro
Thank you, Tom. Maybe it’s interesting to have one code for this in the future.
I’ve activated the Meks plugin, so you can see here, for example, an article with two authors: https://descubrirlahistoria.es/2020/10/obreros-y-estudiantes-contra-el-franquismo-2a-parte-crisis-final-del-regimen-y-transicion/
The problems I see is the image position (maybe it’ll be better aligned left to the text), space margin on the top, and font size (I think is too big).
Thanks again, Tom!
November 17, 2020 at 1:34 pm #1535311Tom
Lead DeveloperLead DeveloperSomething like this may help:
.mks-co-authors-wrapper > a { float: left; margin-right: 1.5em; } .mks-co-authors-wrapper { padding: 20px; background: #fafafa; margin: 15px 0; font-size: 15px; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 17, 2020 at 1:36 pm #1535313Álvaro
Wow, amazing Tom. It’s very nice. Thank you very much for your useful help.
November 17, 2020 at 1:38 pm #1535315Tom
Lead DeveloperLead DeveloperYou’re welcome! 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJanuary 9, 2021 at 4:07 am #1611935Stefan
Hi Tom,
I am looking to to do the same in my blog and I just wanted to double check with you where to insert the codes mentioned above.
Looking forward to your response.
Regards,
StefanJanuary 9, 2021 at 4:33 am #1611950Stefan
Just to add, I am not sure what are the prerequisites in terms of the plugins and also where to insert the following codes:
Plugins: do I need to have both:
– co-authors plus: https://wordpress.org/support/plugin/co-authors-plus/
– meks smart author widge: https://wordpress.org/plugins/meks-smart-author-widget/Codes: (whether I should add) and where to do so for the following codes:
1)add_filter( 'generate_post_author_output', 'tu_co_author_plus' ); function tu_co_author_plus( $author ) { if ( function_exists( 'coauthors_posts_links' ) ) { return ' Por ' . coauthors_posts_links( null, null, null, null, false ); } return $author;
2)
<?php if ( function_exists( 'coauthors_posts_links' ) ) { echo 'Por ' . coauthors_posts_links( null, null, null, null, false ); } ?>
Visuals: I already have the CSS code for the way I would like to author box to look. It’s like the one at the bottom of this link: https://www.lifestyledemocracy.com/how-is-the-revolution-will-not-be-televised-poem-relevant-today-2-2/. What I am missing is the ability to show the second (third and so forth authors) as well as their respective author boxes.
Looking forward to your response.
-
AuthorPosts
- You must be logged in to reply to this topic.