Hi,
I need to add the co authors plugin code snippet, but I’m not sure which file to add it to. I would like the coauthor to show right below the post title: Here is the supposed code I need to replace, but I can’t find it in the theme. Please help.
I need to replace 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();
}
https://www.wpbeginner.com/plugins/allow-multiple-authors-to-be-associated-with-a-post-in-wordpress/
Hi,
In order to achieve that you;ll need to go in wp-includes/author-template.php
https://www.screencast.com/t/VNuQxh9WRiR
Thank you.
I’m trying to make this work for Newsmag, but your instructions seem to work only for Newspaper. Can you post the equivalent instructions for Newsmag? I’ve installed the Co-authors Plus plugin, and I want to be able to credit multiple authors for a single article. Thanks!
Hi,
This is working for Newsmag too -> https://www.screencast.com/t/ekPE4YVf8r75 -> https://www.screencast.com/t/k2dh538m8qLp -> https://www.screencast.com/t/fl2FB8B6f1 -> https://www.screencast.com/t/ohF5wjp0Nouy
All you need to do is to type the name of author.
Thank you!
Thanks. With your help, I was able to find the author-template.php file and make the edits. Now my code looks exactly like your example. But the second author still doesn’t appear on the finished post. I can add a second author when I compose the post, and the post shows up on both authors’ author pages, but the second author’s name doesn’t appear on the post itself. Help? Salvatore
Hi,
Please read this topic: https://forum.tagdiv.com/topic/multiple-authors-co-authors-on-articles-author-links-and-author-boxes/
Try to make a custom modification to implement it for post template that you use – http://screencast.com/t/GOXrK2OTf use this code – http://pastebin.com/chADk3Xw
Result: http://screencast.com/t/oaYBwClZQN – http://screencast.com/t/aOfQUxuL
Thank you.
Hi,
In order to integrate it in single post cloud template you need to change the files that contain the author and author box care tdb_single_author.php and tdb_single_author_box.php and those can be found in wp-content/plugins/td-cloud-library/shortcodes/single/tdb_single_author_box.php
Hope this will help you!
Thank you!
Hi. I added the code you suggested to tdb_single_author.php but found the result of the count was always 1. So needed to use $coauths = get_coauthors(***post ID***);
However, I can’t figure out how to get the post ID!
If I use $post->ID I get the ID of the template, not the ID of the parent post.
Any ideas?
Thanks.
I worked out a way to do it through the SLUG, but if you can simplify this code at all that would be great.
It replaces the single line of code that is in the ‘else’ from the pastebin. The original code is from tdb_single_author.php
Hi @RobGas,
Unfortunately I can not say for sure if this will work or not property with cloud templates, there were no tests with this plugin and our cloud templates, therefor you’ll need to do the custom work your self or find a developer to do it for you.
Support Policy ->https://forum.tagdiv.com/support-policy-2/
Thank you for your understanding!
No worries Calin.
I will leave my latest code in pastebin in case someone finds this thread and needs help with the same thing.
This code is placed in the tdb_single_author.php file.
There is an update on this? the code and files changed since 2018.
Hi,
If you want to use/display more authors on posts you can use a different plugin, the name of plugin is Molongui Authorship and it can be use with cloud templates without need to make changes in theme files.
Hope this will help you and make your work easier!
Let me know the results!
Thank you!
Hi, i think it’s a little late but perhaps this works for somebody 🙂
This is an add for the function render:
//get the js for this block
$buffy .= $this->get_block_js();
function dismount($object)
{
$reflectionClass = new ReflectionClass(get_class($object));
$array = array();
foreach ($reflectionClass->getProperties() as $property) {
$property->setAccessible(true);
$array[$property->getName()] = $property->getValue($object);
$property->setAccessible(false);
}
return $array;
}
$array=dismount($tdb_state_single);
$parcial1=$array[“wp_query”];
$author=cap_get_coauthor_terms_for_post($parcial1->queried_object_id); //function for get the coauthor for post: #####
Right now i’m suffering with a different implementation for the co-author in the post perhaps you could help me:
function render( $atts, $content = null ) {
parent::render( $atts ); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
global $tdb_state_single;
$post_author_data = $tdb_state_single->post_author->__invoke();
$add_text_pos = $this->get_att(‘add_text_pos’);
$buffy = ”; //output buffer
$buffy .= ‘<div class=”‘ . $this->get_block_classes() . ‘ tdb-post-meta” ‘ . $this->get_block_html_atts() . ‘>’;
//get the block css
$buffy .= $this->get_block_css();
//get the js for this block
$buffy .= $this->get_block_js();
//NUEVOS AGREGADOS
if ( function_exists( ‘coauthors_posts_links’ ) )
{
wp_reset_query();
wp_reset_postdata();
$buffy .= ‘<div class=”tdb-author-name-wrap”>’;
$buffy .= ‘<style>
.tdb_single_author a{vertical-align:unset !important;}
</style>’;
$buffy .= ‘<span class=”tdb-author-by”>Por ‘ . coauthors_posts_links( null, null, null, null, false ) . ‘</span> ‘;
}
$buffy .= ‘</div>’;
$buffy .= ‘</div>’;
$buffy .= ‘</div>’;
return $buffy;
}
This print two times my post content i know it’s for the wp_reset_query but i don’t know how to make it work in an easy way, not the hard one.
Hello,
Indeed right not I believe the code is getting both, the cloud CPT template and post content.
Also, in our theme the wp_reset_query() it is used only for standard templates from tagDiv Standard pack.
I asked a developer if he can take a look at the code, but for the moment I didn’t get any reply from hem.
Thank you!