Hi
I would really like to be able to:
1) assign two authors to the same post. And if I do, it needs to show two author boxes on the bottom of the page.
2) create guest authors without creating a WP-account. My authors normally write only one or two posts, and they know nothing about WP.
3) show the name of the author (with a link to author profile page) on the top of the post.
Hope you will consider this. Thanks in advance!
/Thomas
How about a plugin? Maybe Co Authors Plus
-
This reply was modified 12 years by
mbasche.
Hello,
Thanks @mbasche
2. Try Really Simple Guest Post Plugin or similar
3. De comment this http://screencast.com/t/kKcdlkdXapX
Thanks for the message!
Thanks for your answers. I solved number 3 with the de comment.
Regarding number 1 and 2 – I tried with the plugins. Co Authors and Co Authors Plus. I can then create guest authors and assign them to posts, but they don’t show up in the post. No matter what, the post displays only one author – and only the ‘real’ author – not the guest author.
Hope you can help.
I tried that, but I’m no PHP-expert, so I can only follow the plugin support.
I actually made it show the guest author name (only one, not two), but it didn’t integrate well. On the author page it adds the number of post of the guest order and the ‘real’ author.
I am not able to twist the code anymore from here, so I hope tagDiv will consider integrating with the Co Author Plus plugin.
Thanks.
I am trying to integrate this plugin into our site (following these instructions), but having trouble identifying where & how to integrate the template tags.
I think it needs to get added to this code from td_module:
$buffy .= '<span class="td-block-author">';
$buffy .= __td('by', TD_THEME_NAME);
$buffy .= ' ';
$buffy .= '<a itemprop="author" href="' . get_author_posts_url($this->post->post_author) . '">' . get_the_author_meta('display_name', $this->post->post_author) . '</a>' ;
$buffy .= ' - ';
$buffy .= '</span>';
But I can’t figure out exactly what to add. Can you help get me going in the right direction?
Our site is here: http://seattleglobalist.com
And here’s an example of a post with two authors (though they don’t display on the front end currently): http://www.seattleglobalist.com/2013/12/30/an-elusive-japanese-new-years-treat-returns-to-seattle/18592
The get_author_box() function is what Newspaper uses to display Author info on the front end. This function takes a single user ID and generates everything from that. After a quick glance at the code it looks like what needs to be done is to convert the output of the Co-Authors plugin to an array of IDs so that we can iterate over it to get the get_author_box() function to create the boxes using the Author IDs:
First, you would need something like this(assuming you have the Co-Authors Plus plugin installed) in the functions.php:
if(function_exists('coauthors')){
$coauthor_names = coauthors( null, null, null, null, false );
$user_ids = array();
function coauthor_names_to_ids(){
$names = explode(' ', $coauthor_names);
foreach($names as $name){
// We would probably need to add another function here to make sure that the $name matches any one of our authors slugs and then if $name == 'author-slug' then we could procede to get the ID and add it to the $user_IDs array so that we only have an array of valid IDs.
$user = get_user_by( 'slug', wptexturixe($name));
$user_ids[] .= $user->ID;
}
return $user_ids;
}
coauthor_names_to_ids();
}
And then all you would have to do get them to appear on the front end (in td_module_1 for example) is something like this:
//Iterates through the user ids
foreach($user_ids as $coauthor_id){
//creates an author box for each of the coauthor ids
$buffy .= get_author_box($coauthor_id);
}
I haven’t debugged this code, some work would probably need to be done to make sure the exploded $names array matches slugs properly but it appears to be one way to tackle the problem. Another would be to modify the Co-Authors plugin to be able to return the co-author IDs as well as links. I suppose you could also modify the get_author_box() function to accept the author name as an argument…
-
This reply was modified 12 years by
webmaster808. Reason: Forgot to call the function!
I think I’m getting very close to figuring this out, but not quite there…any suggestions much appreciated!
Here’s what we’ve got:
*I am using “Co-Authors Plus” that allows you to assign 2 authors to one post. This is an example: http://www.seattleglobalist.com/2013/12/30/an-elusive-japanese-new-years-treat-returns-to-seattle/18592 this post has two authors on the backend, but only one displays on the post.
*I’ve added template tags to functions.php, per these instructions. and I know it’s kinda sorta working ’cause I can get the two author names to show up (but looking totally weird) by adding a line:
$buffy .= get_coauthors();
to td_module_1.php.
*I *think* that I have to add some kind of conditional to this section of td_module_blog.php, to make this work:
function get_author_box($author_id = '') {
if (!$this->is_single) {
return;
}
if (td_util::get_option('tds_show_author_box') == 'hide') {
return;
}
if (empty($author_id)) {
$author_id = $this->post->post_author;
}
right?? like incorporating something here that says “if there are two authors for this post, then use the coauthors tag instead of the author tag”.
Is that possible?
Thanks!!
No, unfortunately it’s not that easy. It is looking weird because the coauthors boxes are being returned by the Co Authors plugin(using it’s own markup and styling), while the Author box is being returned by the Newspaper Theme’s functions(using different markup and styling). They are not interchangeable.
However, you can choose to use one or the other system in the template.
In your td_module_1(or whatever one, not td_module_blog) you could try replacing $buffy .= $this->get_author_box(); with:
// Get an array of all the co-authors
$my_coauthors = get_coauthors();
// Count the indexes in the array
if(count($my_coauthors) > 1 ){
// There is more than 1 index in $my_coauthors, output all of them with the coauthor plugin function
$buffy .= get_coauthors();
} else {
// There is only one Author, let's output that one with the Theme function
$buffy .= $this->get_author_box();
}
If you want the output of the Co Author’s plugin to look like the output of the Newspaper Theme Author Box, then you have some css work to do.
I just looked at the source of the plugin again and there is a function that returns IDs! Yay!
So in lieu of that, you could try:
// Lets get the IDs of the co-authors
$user_ids = get_coauthors_IDs();
//Iterates through the user ids
foreach($user_ids as $coauthor_id){
//creates an author box for each of the coauthor ids
$buffy .= get_author_box($coauthor_id);
}
If this works, it will only work for co-authors that have an author account in your system that has a unique email address, not the pseudo ones that the plugin can create.
Arrg! I am sure it’s so close to working, but I can’t get it to. Thank you so much for your help, but when I insert the code it just keeps breaking the page.
@partnowjess hello! I saw now your theme works fine with the two authors in loop too. May you explain how do you made this please? my co author plus works just on single pages 🙁
Here is the code we came up with:
//$buffy .= $this->get_author();
$coauths = get_coauthors();
$coauthsHTML = '';
if (count($coauths) > 1) {
$coauthsHTML .= "by ";
foreach($coauths as $coauth) {
$coauthsHTML .= '<a href="/author/'.$coauth->user_nicename.'">'.$coauth->display_name.'</a> and ';
}
$coauthsHTML = substr($coauthsHTML, 0, -4);
$buffy .= $coauthsHTML;
}else{
$buffy .= $this->get_author();
}
It shows up in most of the includes/modules files. I just looked for everywhere this line exists:
$buffy .= $this->get_author();
And replaced it with the above. Hope that helps!
Hi,
@mbasche yes.. you are right, the code snippets are from an older version of newspaper.
@lucioluci the code snippet provided by @partnowjess has to be modified to work in the current version.
http://screencast.com/t/ehsvNrSegqf
current version of the code (not tested yet):
<?
//$buffy .= $this->get_author();
$coauths = get_coauthors();
if (count($coauths) > 1) {
echo "by ";
foreach($coauths as $key => $coauth) {
echo '<a href="/author/'.$coauth->user_nicename.'">'.$coauth->display_name.'</a>';
// add "and"
if ($key != count($coauths)) {
echo ' and ';
}
}
} else {
echo $this->get_author();
}
Thank You all!
Just a last thing: which code i have to put in the theme function.php? I put the code by @radu in my module 9 but still see just one author 🙁
<div class="meta-info">
<?
//$buffy .= $this->get_author();
$coauths = get_coauthors();
if (count($coauths) > 1) {
echo "by ";
foreach($coauths as $key => $coauth) {
echo '<a href="/author/'.$coauth->user_nicename.'">'.$coauth->display_name.'</a>';
// add "and"
if ($key != count($coauths)) {
echo ' and ';
}
}
} else {
echo $this->get_author();
}
?>
<?php echo $this->get_date();?>
<?php echo $this->get_commentsAndViews();?>
</div>
Hello everybody,
i could made co authors works in post http://www.questeistituzioni.it/cosa-e-la-fatturazione-elettronica-pubblica-amministrazione-2038
but not in home 🙁
i put the code by @partnowjess in module 9 (the “last post” in home) but it does not show the two authors 🙁
i put this code in functions.php
function hybrid_entry_author_shortcode( $attr ) {
$attr = shortcode_atts( array( 'before' => '', 'after' => '' ), $attr );
if ( function_exists( 'coauthors_posts_links' ) ) {
$author = coauthors_posts_links( null, null, null, null, false );
} else {
$author = '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . '">' . get_the_author_meta( 'display_name' ) . '</a></span>';
}
return $attr['before'] . $author . $attr['after'];
}
This is sadly out of date now that 4 is out, I think.
I wish there were just some easy guide like this:
“So you want to use Co-Authors Plus to have as many Newspaper-theme author boxes as there are authors.
1. Go to your theme editor.
2. Find the file …
3. Find the lines …
4. Replace with / add the lines …
5. Profit!!”
