WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Co Authors First and Last names (4 posts)

  1. lowestofthekeys
    Member
    Posted 1 year ago #

    Hi all.

    First off, Daniel this is wonderful plugin, bu tI think I'm missing a function for what I want it to do.

    I am attempting to list out the co authors at the beginning of the article after "By:"

    I used<?php if ( function_exists( 'coauthors' ) ) { coauthors(); } else { the_author(); } ?>

    But unfortunately it refers to their usernames instead of the first and last names.

    Is there a snippet that will allow me to list two authors by first and last name? For examples, I want it to look likes this: "By: Joe Smith and Alex Vasquez."

    http://wordpress.org/extend/plugins/co-authors-plus/

  2. lowestofthekeys
    Member
    Posted 1 year ago #

    Argh ignore this.

    I checked my functions.php and realized there was some old code in there taking out the "display name as" option under "edit users."

    *removes foot from mouth*

  3. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Cool, that's what I was going to suggest :) Glad you figured it it out

  4. dvm2109
    Member
    Posted 1 year ago #

    Dear Daniel, thanks a lot of all for this great plugin! I'm using it on a blog with more than 70 authors and it helps me a lot.

    Like Jon I wanted to change the displayed name to first and last name. Manually changing the "display name as" option for every user, however, was not an option and I don't really trust the plugins that purport to do so.

    My suggestion thus would be to add a function coauthors_fullnames. I don't know enough about coding to do this, so I had to come up with a little workaround.

    I changed the function coauthors_lastname so that it returns an empty value:

    function coauthors_lastnames($between = null, $betweenLast = null, $before = null, $after = null, $echo = true ) {
    	return coauthors__echo('get_the_author_meta', 'tag', array(
    		'between' => $between,
    		'betweenLast' => $betweenLast,
    		'before' => $before,
    		'after' => $after
    	), '', $echo);
    }

    This then triggers your fallback function, which I modified as follows:

    // Fallback to user_login if we get something empty
    		if( empty( $author_text ) )
    			$author_text1 = $i->current_author->user_firstname;
    			$author_text2 = $i->current_author->user_lastname;
    			$author_text = "$author_text1 $author_text2";

    I know this is far from elegant, but it works!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic