-
AuthorPosts
-
January 25, 2016 at 6:51 pm #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
January 26, 2016 at 2:31 am #571792Hi 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.
January 26, 2016 at 11:16 am #572021Hi 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!
MarkusJanuary 27, 2016 at 11:01 pm #573303Hi,
Can you post the link to your website please?
Regards,
JosueJanuary 29, 2016 at 2:57 pm #574569I’m working on a local installation on my computer, but will upload it to a server post the link asap!
Thanks,
Markus
January 29, 2016 at 4:20 pm #574625January 30, 2016 at 2:39 pm #575003Hello, 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!
February 1, 2016 at 3:46 am #575500Hey!
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,
ElliottFebruary 1, 2016 at 11:10 am #575673Ok! 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
February 2, 2016 at 6:01 am #576245Hi,
Not sure if we have any more advice to give you unfortunately, but please share any progress you may have.
Best regards,
RikardFebruary 3, 2016 at 9:00 pm #577344Hello 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
February 4, 2016 at 4:03 am #577508Thanks for sharing your solution Markus, it will certainly help someone :)
Regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.