[Support request] Showing multiple authors using Co-Authors Plus plugin

Home Forums Support [Support request] Showing multiple authors using Co-Authors Plus plugin

Home Forums Support Showing multiple authors using Co-Authors Plus plugin

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #732714
    Luca

    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,
    Luca

    #732801
    Tom
    Lead Developer
    Lead Developer

    Hey 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 🙂

    #732959
    Luca

    Hi 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,
    Luca

    #733583
    Tom
    Lead Developer
    Lead Developer

    Can you link me to one of those posts with multiple authors?

    #733704
    Luca
    #733731
    Tom
    Lead Developer
    Lead Developer

    Aha, you’re using the Header Element.

    This should help: https://generatepress.com/forums/topic/co-authors-plus-page-headers/#post-540499

    #734065
    Luca

    Hi 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!

    #734759
    David
    Staff
    Customer Support

    Hi there,

    does the short code render on its own? ie. no other content in the hero?

    #734917
    Luca

    Hi 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,
    Luca

    #735133
    David
    Staff
    Customer Support

    Sorry, i meant in the Page Header. So just add the shortcode and nothing else and see if then renders

    #735337
    Luca

    Hi 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/

    #735824
    David
    Staff
    Customer Support

    Any 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.

    https://generatepress.com/contact/

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