- This topic has 11 replies, 3 voices, and was last updated 5 years, 4 months ago by David.
-
AuthorPosts
-
November 20, 2018 at 2:25 pm #732714Luca
Hi everybody,
with some friends we started an association and are starting to setup our website.Some of the posts we’ll write have multiple authors and following the following tutorial
we managed to have multiple authors contributing to the same post.https://www.wpbeginner.com/plugins/allow-multiple-authors-to-be-associated-with-a-post-in-wordpress/
The only thing that is left is to have GeneratePress show all the authors. In the tutorial they say:
You will be looking for the code with template tag the_author_posts_link() and you will need to replace it with the following code snippet.
if ( function_exists( ‘coauthors_posts_links’ ) ) {
coauthors_posts_links();
} else {
the_author_posts_link();
}To me it’s not clear how to add this in GeneratePress, I couldn’t find a place where “the_author_posts_link()” is used ( I checked in several of the theme php files without luck).
In the forum I have found a topic where they say use the Code Snippets plugin but I don’t think it applies to this case, am I correct?
Could you help me set this up?
Thanks a lot for the help,
LucaNovember 20, 2018 at 4:10 pm #732801TomLead DeveloperLead DeveloperHey Luca,
Give this function a try:
add_filter( 'generate_post_author_output', function( $author ) { if ( function_exists( 'coauthors_posts_links' ) ) { return sprintf( ' <span class="byline">%1$s</span>', coauthors_posts_links( null, null, null, null, false ) ); } return $author; } );
Adding CSS: https://docs.generatepress.com/article/adding-php/
Let me know if this helps or not 🙂
November 20, 2018 at 10:43 pm #732959LucaHi Tom,
thanks a lot for the help.Unfortunately this didn’t seem to help.
The steps I followed:
Installed the plugins Code Snippets.
Activated the plugin.
Created a new Snippet (on the top it says <?php so I think it should be right)
and copied and pasted your code.Below the code I selected the option “Run everywhere”
I clicked on Save and Activate.Went to the post with multiple authors (the post is Scheduled for 22 Nov 2050, to avoid that we accidentally publish it before it’s finished), I added some content and clicked on “Update”.
After the post has been saved I clicked on “Preview”.In the preview tab only the first author is showed.
Did I do something wrong?
Thanks a lot again!
Cheers,
LucaNovember 21, 2018 at 9:27 am #733583TomLead DeveloperLead DeveloperCan you link me to one of those posts with multiple authors?
November 21, 2018 at 11:35 am #733704LucaHi Tom,
sure here it is https://badass.cat/2018/11/20/test-multiple-authors/November 21, 2018 at 12:05 pm #733731TomLead DeveloperLead DeveloperAha, you’re using the Header Element.
This should help: https://generatepress.com/forums/topic/co-authors-plus-page-headers/#post-540499
November 21, 2018 at 10:46 pm #734065LucaHi Tom,
thanks for the help but it didn’t seem to help.I did the following:
created a Snippet of code where I copied and pasted
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 ) : '' ); }
I clicked on Save and Activate. Next I went to Appearance -> Elements
and edited one called “Post” (where effectively there is a placeholder called {{post_author}}, I wasn’t aware of it).I wrote
[author_plus]
in this element and saved, but the website shows[author_plus]
instead of the author names (i.e. it seems that the shortcode is not rendered).Thanks for the help!
November 22, 2018 at 9:24 am #734759DavidStaffCustomer SupportHi there,
does the short code render on its own? ie. no other content in the hero?
November 22, 2018 at 11:58 am #734917LucaHi David,
thanks for answering.Unfortunately I have no idea:) I am no wordpress expert,
I just set up GeneratePress and selected on of the available templates that comes with it.I have no knowledge of WordPress nor php, so if you tell me how I can check what is this Hero and if I have it, but can’t help you more at the moment.
Cheers,
LucaNovember 22, 2018 at 3:38 pm #735133DavidStaffCustomer SupportSorry, i meant in the Page Header. So just add the shortcode and nothing else and see if then renders
November 22, 2018 at 10:16 pm #735337LucaHi David,
I tried to leave only the shortcode but it doesn’t work.Now on the top of the page it writes
[authors_plus]
then below (seems another div section) there are the title and the author name and the date. You can che how it appears here: https://badass.cat/2018/11/20/test-multiple-authors/
November 23, 2018 at 5:07 am #735824DavidStaffCustomer SupportAny chance you can provide us with temporary admin access to the site?
You can send details via the Account Issue form, please add the URL to this topic so we can keep track. -
AuthorPosts
- You must be logged in to reply to this topic.