I needed multiple authors names below the title and multiple authors boxes on articles. Using the various solutions found on this forum I have compiled a complete solution
Plugin used: Co Authors Plus 3.2.2
Multiple authors links below the article title
Modified files: find the file template that you want to use > loop-single.php, loop-single(1, 5, 9, 10).php, single_template_(2, 3, 4, 6, 7, 8, 11, 12, 13).php,
Replace this:
<?php echo $td_mod_single->get_author();?>
With:
<?php
if (td_util::get_option(‘tds_p_show_author_name’) != ‘hide’) {
//echo $td_mod_single->get_author();
$coauths = get_coauthors();
if (count($coauths) > 1) {
echo ‘<div class=”td-post-author-name multiple-authors”><div class=”td-author-by”>De către</div>’;
foreach ($coauths as $key => $coauth) {
echo ‘user_nicename . ‘”>’ . $coauth->display_name . ‘‘;
}
echo ‘<div class=”td-author-line”> – </div></div>’;
} else {
echo $td_mod_single->get_author();
};
}?>
CSS:
header .td-post-author-name.multiple-authors a {
margin-right: 0;
}
header .td-post-author-name.multiple-authors .td-author-by {
margin-right: 5px;
}
.td-post-author-name.multiple-authors a:after {
content:”,”;
margin-right: 6px;
}
.td-post-author-name.multiple-authors a:last-of-type:after {
content:””;
margin-right: 3px;
}
Multiple authors boxes on article page
Modified files: find the file template that you want to use > loop-single.php, loop-single(1-13).php
Replace this:
<?php echo $td_mod_single->get_author_box();?>
With:
<?php
if (td_util::get_option(‘tds_show_author_box’) != ‘hide’) {
//echo $td_mod_single->get_author_box();
$coauths = get_coauthors();
if (count($coauths) > 1) {
echo ‘<div class=”author-box-list”>’;
foreach ($coauths as $key => $coauth) {
echo ‘<div class=”author-box-wrap”>user_nicename . ‘”>’;
echo get_avatar( $coauth->user_email, ’96’ );
echo ‘<div class=”desc”><div class=”td-author-name vcard author”><span class=”fn”>user_nicename . ‘”>’ . $coauth->display_name . ‘</span></div>’;
echo ‘<div class=”td-author-description”>’ . $coauth->description . ‘</div>’;
echo ‘</div><div class=”clearfix”></div></div>’;
}
echo ‘</div>’;
} else {
echo $td_mod_single->get_author_box();
};
}?>
Note: the multiple author boxes will work only with default users gravatar, not with the custom avatar plugins
Hope that helps
For some reasons the php code is broken after I publish the post and I cannot edit the post anymore.
The correct code is here:
Plugin used: Co Authors Plus 3.2.2
Multiple authors links below the article title
Modified files: find the file template that you want to use > loop-single.php, loop-single(1, 5, 9, 10).php, single_template_(2, 3, 4, 6, 7, 8, 11, 12, 13).php,
Replace this:
<?php echo $td_mod_single->get_author();?>
With: https://pastebin.com/7Y8kpfTy
CSS:
header .td-post-author-name.multiple-authors a {
margin-right: 0;
}
header .td-post-author-name.multiple-authors .td-author-by {
margin-right: 5px;
}
.td-post-author-name.multiple-authors a:after {
content:”,”;
margin-right: 6px;
}
.td-post-author-name.multiple-authors a:last-of-type:after {
content:””;
margin-right: 3px;
}
Multiple authors boxes on article page
Modified files: find the file template that you want to use > loop-single.php, loop-single(1-13).php
Replace this:
<?php echo $td_mod_single->get_author_box();?>
hello, I want to express my gratitude. I really appreciate you taking your time to post this solution.
I wondered if you were able to get it to show up on any of the blocks which would load story snippets dynamically.
When i was experimenting with implementing this plug-in i found the blocks author byline was controlled by \includes\wp_booster\td_module.php lines 119-135 but i was unable to correctly implement it. when i tried, it would inherent the page author instead of the author for each of the posts.
Any help would be greatly appreciated
just a heads up, i was able to get the social icons on the author box by adding this code
echo '<div class="td-author-social">';
foreach (td_social_icons::$td_social_icons_array as $td_social_id => $td_social_name) {
//echo get_the_author_meta($td_social_id) . '<br>';
$authorMeta = get_the_author_meta($td_social_id, $coauth->ID);
if (!empty($authorMeta)) {
echo td_social_icons::get_icon($authorMeta, $td_social_id, true);
}
}
echo '</div>';
after
echo '<div class="td-author-description">' . $coauth->description . '</div>'; on your code
the entire code for that segment being:
<?php
if (td_util::get_option('tds_show_author_box') != 'hide') {
//echo $td_mod_single->get_author_box();
$coauths = get_coauthors();
if (count($coauths) > 1) {
echo '<div class="author-box-list">';
foreach ($coauths as $key => $coauth) {
echo '<div class="author-box-wrap">user_nicename . '">';
echo get_avatar( $coauth->user_email, '96' );
echo '<div class="desc"><div class="td-author-name vcard author"><span class="fn">user_nicename . '">' . $coauth->display_name . '</span></div>';
echo '<div class="td-author-description">' . $coauth->description . '</div>';
echo '<div class="td-author-social">';
foreach (td_social_icons::$td_social_icons_array as $td_social_id => $td_social_name) {
//echo get_the_author_meta($td_social_id) . '<br>';
$authorMeta = get_the_author_meta($td_social_id, $coauth->ID);
if (!empty($authorMeta)) {
echo td_social_icons::get_icon($authorMeta, $td_social_id, true);
}
}
echo '</div>';
echo '</div><div class="clearfix"></div></div>';
}
echo '</div>';
} else {
echo $td_mod_single->get_author_box();
};
}?>
Here is the code for the blocks:
1. File: wp-content\themes\Newspaper\includes\wp-booster\td_module.php
Add this: https://pastebin.com/KsfC74zm below the author section
2. Locate the block that you want to use (ex: wp-content\themes\Newspaper\includes\modules\td_module_17.php
Replace this:
<?php echo $this->get_author();?>
With this:
<?php echo $this->get_coauthors();?>
Thanks for posting this solution!
We are using NewsMag, and I was able to get the co-author setup on the post (https://www.bizavadvisor.com/2020-vision/), but cannot seem to get the co-author to display on our home page using Module 4. Any help would be appreciated.
using vlad1984’s solution worked for me. all i to do was identify which templates used which blocks.
Here is the code for the blocks:
1. File: wp-content\themes\Newspaper\includes\wp-booster\td_module.php
Add this: https://pastebin.com/KsfC74zm below the author section
2. Locate the block that you want to use (ex: wp-content\themes\Newspaper\includes\modules\td_module_17.php
Replace this:
<?php echo $this->get_author();?>
With this:
<?php echo $this->get_coauthors();?>
@vlad1984, You sir, are a genious!! Was looking for hours for a solution. This was my last resort and it worked! And thanks to @ouchmyego for the social icons, looks great now 🙂
Example on our website: https://haerlemsbodem.nl/m-h-r-puttmann-exceptionele-schoonheid-ouderdom-haerlemse-vrouwen/
edit single.php under themes/Newspaper/mobile/
*note this fix cannot be done in a child-theme, if youre using a child theme, edit the single.php thats in the actual theme
this is what i did, see below
<div class="td-module-meta-info">
<?php
if ( function_exists( 'coauthors_posts_links' ) )
?>
<div class="td-post-author-name"><div class="td-author-by">By
<?php coauthors_posts_links(); ?>
</div></div>
<?php //echo $td_mod_single->get_author();?>
<?php echo $td_mod_single->get_date(false);?>
<?php echo $td_mod_single->get_comments();?>
<?php echo $td_mod_single->get_views();?>
</div>
Hi, thanks for this info. I tried to add the codes in my “loop-single.php” and “loop-single-1.php” files, because I’m using the default template for my posts. However, it still displays the same. Please help. My website is: https://rachelrooi.com
Following this post I’ve managed to get this working with a child theme. Thanks @vlad1984 and @ouchmyego.
The only place I’ve had to change the parent theme files is in the changes to wp-content\themes\Newspaper\includes\wp-booster\td_module.php – adding this into the child theme didn’t work.
There seems to be contradictory information in the instructions here https://forum.tagdiv.com/the-child-theme-support-tutorial/ – are some files in the wp-booster supported in child themes and some not? @bogdan-b, can you help on that?
Hi,
@curve The file you mention cannot be modified through a child theme. The files that can be modified from the booster folder are mentioned in the child theme guide
– https://www.screencast.com/t/HP1IrDRi6O
So you will have to make the modification in the main theme file in order for this to work.
Thanks
Hi,
@Marcus_S You could try something like this for example
– https://www.screencast.com/t/Laffco6n
You can make the code more precise if needed, by block or module type
.td-post-author-name:not(:first-child):before {
content:"/";
}
Thanks
Hey all.. MAybe if you-re willing to use the help of a plugin you could try this one: https://molongui.amitzy.com/product/authorship/ … Haven’t tested it with my Newspaper theme, but apparently “so far, so good” with another theme I installed it on.
Notes:
The free version works fine, but it’s very very limited on the design options.
-
This reply was modified 8 years by
guaser. Reason: adding a foot note
Hi, a fantastic bit of code, but sadly all my authors are right next to each other without a space or preferrably a comma, even with the additional css. any thoughts ? thanks 🙂
Please, tell me it is possible to integrate Co-Authors Plus in Newspaper in easiest way, without problem after future updating theme and editing all files?
Maybe adding in theme file functions.php something like (i don’t know):
if ( function_exists( 'coauthors_posts_links' ) ) {
$get_author = coauthors_posts_links();
} else {
$get_author = get_author();
}