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

    Hello there,

    I’m integrating the “Co-Authors Plus” plugin to be able to work with multiple authors per post. I know you guys can’t provide support for third-party plugins, but maybe you can point me in the right direction how to go about it.

    I’m trying to display the list of authors in a Masonry element next to the date. I’ve modified config-templatebuilder/avia-shortcodes/helper-masonry.php to display a single author name already.

    I see that $author gets set in line 394 in helper-masonry.php:
    $author = apply_filters(‘avf_author_name’, get_the_author_meta(‘display_name’, $entry->post_author), $entry->post_author);

    My questions:
    – Any tips how to correctly replace the single author name with the full list of authors? (for reference: https://vip.wordpress.com/documentation/incorporate-co-authors-plus-template-tags-into-your-theme/)
    – What exactly is the purpose of the apply_filters function here?

    Thank you!

    Markus

    #571792

    Hi makimono!

    Maybe something like this?

    add_filter( 'avf_author_name', 'enfold_customization_switch_authors' );
    function enfold_customization_switch_authors( $author ) {
        return coauthors__echo('display_name', 'field', array(
            'between' => null,
            'betweenLast' => null,
            'before' => null,
            'after' => null
        ), null, false );
    }

    Regards,
    Elliott

    • This reply was modified 8 years, 10 months ago by Elliott.
    #572021

    Hi Elliott,

    Thanks so much, that already helped a lot!

    I added your add_filter function to functions.php of my child theme and now multiple authors are shown.

    Unfortunately all Masonry items now show the author(s) of the current page that contains the Masonry item, whereas it should show the author(s) of the blog post each respective Masonry item is representing.

    Just to avoid any confusion:
    The page containing the Masonry item was created by “Jack” and “John”. Currently all Masonry items display “by Jack and John”, even if the posts they link to were created by other people.

    Any tips how I can display the correct authors for each individual Masonry item?

    Thank you!
    Markus

    #573303

    Hi,

    Can you post the link to your website please?

    Regards,
    Josue

    #574569

    I’m working on a local installation on my computer, but will upload it to a server post the link asap!

    Thanks,

    Markus

    #574625

    Hey Markus!

    We will keep thread open and wait to hear from you.

    Best regards,
    Yigit

    #575003

    Hello, I’ve uploaded the site. Please see login credentials in the private message. Hope everything is clear. Let me know if you need anything else!

    #575500

    Hey!

    I flagged this for Josue but I think your going to have to contact the plugin authors. It looks like it was only meant to be used on the single posts and not on post listings.

    Best regards,
    Elliott

    #575673

    Ok! Thanks for your time so far. I will try to figure it out and share the result here if successful. In the meantime, any further tips are much appreciated!

    best wishes,

    Markus

    #576245

    Hi,

    Not sure if we have any more advice to give you unfortunately, but please share any progress you may have.

    Best regards,
    Rikard

    #577344

    Hello there,

    I found a solution. In functions.php of the child theme I added this filter:

    if( function_exists('get_coauthors') ) {
        add_filter( 'avf_author_name', 'masonry_filter_authors', 10, 2 );
        
        function masonry_filter_authors( $author, $post ) {
            $coauthors = get_coauthors( $post->ID );
            $authorsCollection = array();
            foreach( $coauthors as $coauthor ) {
                if( $coauthor->display_name ) {
                    $authorsCollection[] = $coauthor->display_name;
                }
            }
            return implode(', ', $authorsCollection);
        }
    }

    and I had to change (via child theme overload) helper-masonry.php slightly in line 394:

    $author = apply_filters('avf_author_name', get_the_author_meta('display_name', $entry->post_author), $entry);

    the important part is the last $entry at the end.

    Hope this is a sound solution, and that it might help someone!

    all the best,

    Markus

    #577508

    Thanks for sharing your solution Markus, it will certainly help someone :)

    Regards,
    Josue

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