I´m using Co-Authors Plus plugin to manage multiple authors in a e-magazine, but I´m trying to go further and credit “text authors”, “photography authors” and “video authors”, so I´m adding a new field in the author´s profile to specify a role (writer, photographer, videographer) and trying to show the extra meta information in single.php and in the frontpage (through a widget).
This is the new function in functions.php:
// Add Twitter, Facebook and Role profile field in user profiles.
function add_twitter_contactmethod( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
// Add Facebook
$contactmethods['facebook'] = 'Facebook';
// Add Role
$contactmethods['role'] = 'Role (writer / photo / video)';
return $contactmethods;
}
add_filter('user_contactmethods','add_twitter_contactmethod',10,1);
And this is the output in single.php and in the widget, which is intended to show the role before the author´s name and a link to the Twitter or Facebook account (e.g. Text: John Doe @johndoe · Photo: John Williams @photowilliams):
<?php $i = new CoAuthorsIterator(); ?>
<span class="post-meta"><?php while($i->iterate()){ ?>
<?php if(get_the_author_meta('role') == "writer"){ ?>
<span class="author-social text"><?php _e('Text:','alegria'); ?>
<?php } else { ?>
<span class="author-social photo"><?php _e('Photo:','alegria'); ?>
<?php } ;?></span>
<?php the_author_posts_link(); ?>
<?php if(get_the_author_meta('twitter')) : ?>
<a href="http://twitter.com/<?php echo the_author_meta('twitter'); ?>" class="author-twitter" title="Follow <?php echo $authorname; ?> on Twitter">@<?php echo the_author_meta('twitter'); ?></a>
<?php endif ;?>
This works fine, but I´ve been trying to add a third possibility, which involves the role “video” (if the role is “video”, then show “Video:” before the author´s name.
I´ve been dealing with new instances of “if(get_the_author_meta(‘role’)” and “elseif”, but in a intuitive way, since I´m not a programmer and know very little about PHP and conditional sentences.
Could anybody point me in the right way to achieve what I´m looking for?
Thank you.