[Resolved] Integrating Co-Authors Plus

Home Forums Support [Resolved] Integrating Co-Authors Plus

Home Forums Support Integrating Co-Authors Plus

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1163922
    Marcel

    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.

    #1164347
    Tom
    Lead Developer
    Lead Developer
    #1164405
    Marcel

    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;
    } );
    #1164415
    Leo
    Staff
    Customer Support

    Yup or one of these methods:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1165152
    Marcel

    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?

    #1165396
    David
    Staff
    Customer Support

    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

    #1165406
    Marcel

    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?

    #1165409
    David
    Staff
    Customer Support

    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>

    #1165416
    Marcel

    Awesome! It works! Thank you so much for all your help!

    #1165425
    David
    Staff
    Customer Support

    Glad we could all be of help

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.