- This topic has 9 replies, 4 voices, and was last updated 4 years, 1 month ago by David.
-
AuthorPosts
-
February 13, 2020 at 4:24 am #1163922Marcel
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.
February 13, 2020 at 8:54 am #1164347TomLead DeveloperLead DeveloperHi there,
Give this a shot: https://generatepress.com/forums/topic/showing-multiple-authors-using-co-authors-plus-plugin/#post-732801
Let me know 🙂
February 13, 2020 at 9:48 am #1164405MarcelSo 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; } );
February 13, 2020 at 9:56 am #1164415LeoStaffCustomer SupportYup or one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/February 14, 2020 at 6:22 am #1165152MarcelHi 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?
February 14, 2020 at 7:01 am #1165396DavidStaffCustomer SupportHi 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
February 14, 2020 at 7:08 am #1165406MarcelHi 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?
February 14, 2020 at 7:12 am #1165409DavidStaffCustomer SupportYou 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>
February 14, 2020 at 7:22 am #1165416MarcelAwesome! It works! Thank you so much for all your help!
February 14, 2020 at 7:40 am #1165425DavidStaffCustomer SupportGlad we could all be of help
-
AuthorPosts
- You must be logged in to reply to this topic.