Archived topic
Integrating Co-Authors Plus
9 replies · Started by Marcel on February 13, 2020
Hi,
I'm trying to integrate the plugin Co-Authors Plus with the GeneratePress theme but I'm not sure about the code I need to use. As a reference please check: https://wpvip.com/documentation/incorporate-co-authors-plus-template-tags-into-your-theme/.
I hope you can help.
Thank you in advance.
Hi there,
Give this a shot: https://generatepress.com/forums/topic/showing-multiple-authors-using-co-authors-plus-plugin/#post-732801
Let me know :)
So do I add this to functions.php?
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;
} );
Yup or one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/
Hi Leo,
I can see that the authors changed on the Search Results pages. For example: https://entrepreneurcaribbean.com/?s=leadership
But it didn't change it in an element I'm using. I'm using this in an element: <span id="ph-author">{{post_author}}</span><span id="ph-date">{{post_date}}</span>
Do I need to change that as well?
Hi there,
Tom provides another PHP Snippet here that will create a shortcode you can add to the Header Element:
https://generatepress.com/forums/topic/co-authors-plus-page-headers/#post-540499
Hi David, thanks for pointing that out.
But I tried these three lines of code but none of them work:
<span id="ph-author">[author_plus]</span><span id="ph-date">{{post_date}}</span>
<span id="ph-author">{{author_plus}}</span><span id="ph-date">{{post_date}}</span>
<span id="ph-author">{{[author_plus]}}</span><span id="ph-date">{{post_date}}</span>
Am I doing something terribly wrong?
You need to add this to Theme:
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 ) : ''
);
}
Using one of the methods here:
https://docs.generatepress.com/article/adding-php/
Then add this to your Header Element:
<span id="ph-author">[author_plus]</span><span id="ph-date">{{post_date}}</span>
Awesome! It works! Thank you so much for all your help!
Glad we could all be of help