Multiple authors for Greatmag

Hello,

First of all, thank you very much for the template Greatmag. It works well and it is really nice!

I am publishing articles written by multiple authors, and I would like to show their names. For that reason, I have installed the plugin Co-Authors, and I have followed this tutorial.

However, I cannot find this code in the template : the_author_posts_link(). So, I don’t know where to copy/past the following code provided in the tutorial:
if ( function_exists( 'coauthors_posts_links' ) ) {

coauthors_posts_links();

} else {

the_author_posts_link();

}

Do you know the changes I should make to display the names of the authors?

Here is an article with two authors: https://www.european-datalab.com/lassurance-chomage-en-europe-une-analyse-des-differents-systemes/

I am using a child theme.

Thank you,
David

Hello David,

I cannot find this code in the template : the_author_posts_link() . So, I don’t know where to copy/past the following code provided in the tutorial

the_author_posts_link() function is converted into a wrapper for get_the_author_posts_link() function since WordPress 4.4:
https://developer.wordpress.org/reference/functions/the_author_posts_link/#changelog

get_the_author_posts_link() function is in inc/template-tags.php file, row 32.

Please feel free to ask any other questions that you might have.

Kind Regards, Roman.
aThemes Support

Hello Roman,

Sorry for the delay, but I struggled to find a solution even with your indication.

Based on this discussion, I wrote the following code that I put in my file functions.php in my child theme:

function greatmag_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
	$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}

$time_string = sprintf( $time_string,
	esc_attr( get_the_date( 'c' ) ),
	esc_html( get_the_date() ),
	esc_attr( get_the_modified_date( 'c' ) ),
	esc_html( get_the_modified_date() )
);

$posted_on = sprintf(
	esc_html_x( 'Posted on %s', 'post date', 'greatmag' ),
	'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);

if ( function_exists( 'coauthors_posts_links' ) ) {
   	$byline = sprintf(
		_x( '%s', 'post author', 'greatmag' ),
		'<span class="author vcard">'.coauthors_posts_links(null,null,null,null,false).'</span>'
	);
} else {
    $byline = sprintf(
		_x( '%s', 'post author', 'greatmag' ),
		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
	);
}

$meta = '<h5 class="post-meta"><a href="' . '" class="author vcard">' . $byline . '</a>  -  <a href="' . esc_url( get_the_permalink() ) . '" class="date">' . $time_string . '</a></h5>';

echo $meta;

}

I don’t know if my code is 100 % correct, but it works.

Thank you,
David

1 Like