Archived topic
Adding a Co-Author to the Generate Press Author Box
7 replies · Started by Stefan on May 22, 2022
Hi,
I followed the excellent video and instructions on this YouTube video to create my own author box in Generate Press.
I would appreciate your assistance on adding a single or multiple co-authors and have an author box be generated dynamically for each author and co-author.
I use the Co-authors Plus to generate the second or multiple co-authors in particular blog posts.
Please let me know if you can assist me. In the private link below, I am including a sample blog post that has two authors.
Regards,
Stefan
Hi Stefan,
May we know how the plugin allows the co-author data to be retrieved?
For instance, usually, the co-author is saved as a post meta with a specific meta field name.
Kindly let us know. :)
Hi Fernando,
First, the authors must be entered as users, i.e, they must have a particular role on the website (it can be Contributors, Administrators, Editors, etc.)
There are two ways that this can be toggled. One from the "Page" section. Going to "Quick Edit" one can select the "co-author."
The other way is in the post itself, there is an option to add multiple co-authors.
You can see the screenshots in the private message section.
I do not understand the backend very well, but I hope this helps.
Hi Stefan,
Unfortuanly we have no way to know how the plugin adds co-author.
Can you contact the plugin support and ask them how to call the co-author? Is it stored as post meta?
Let me know!
Hi,
Does this link and info help.
https://wordpress.org/plugins/co-authors-plus/
Can I easily create a list of all co-authors?
Yep! There’s a template tag called coauthors_wp_list_authors() that accepts many of the same arguments as wp_list_authors(). Look in template-tags.php for more details.
You can try adding a PHP snippet like this through a plugin like Code Snippets:
add_shortcode( 'author_plus', 'tu_coauthors_plus_shortcode' );
function tu_coauthors_plus_shortcode() {
return sprintf( ' <span class="byline">%1$s</span>',
function_exists( 'coauthors_posts_links' ) ? coauthors_posts_links( null, null, null, null, false ) : ''
);
}
Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets
Then, add a Shortcode Block - [author_plus] to your Author Box as such: https://share.getcloudapp.com/z8ump6XN
This should make the authors appear.
Kindly let us know how it goes. :)
Hi Fernando,
Thanks for the support.
Both authors appear now, but I think that we may not have been on the same page.
I would like the same author box that I developed using the instructions from Leo about the main author to be re-created when two or more authors have authored a blog post.
In the link shared in the private window you can see the box. You can see that below my author box are the names of the two authors (in this case). However, I wanted to have something like the second screenshot.
It would be great if this could be done via some kind of those GP magic blocks that simplify life.
Thanks again for your patience.
Regards,
Stefan
Hi Stefan,
Fernando's code is simply using the template tags that the plugin provided.
The plugin doesn't provide a template tag to return the co-author without the author.
Can you contact the plugin's support asking for the template tag for only the co-author and the co-author's user meta like description?