Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am working on a function that displays all authors but it appears I am doing something wrong the HTML within does not display until the bottom of the page separate from the output.

/* Add shortcode to display authors */
function all_authors() {
global $wpdb;

$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users where ID not in(1)");

$retval = '<div id="author_list"><ul>';
foreach($authors as $author) {
$retval .= '<li>';
if(userphoto_exists($author->ID))
    echo userphoto($author->ID);
else
$retval .= get_avatar($author->ID, 96);
$retval .= '<h6>'.the_author_meta('display_name', $author->ID).', '.the_author_meta('tagline', $author->ID);
$retval .= '</h6><p>'.the_author_meta('description', $author->ID).'</p><p><strong>'.the_author_meta('phone', $author->ID);
$retval .= ' | <a href="'.the_author_meta('user_url', $author->ID).'" target="_blank">'.the_author_meta('user_url', $author->ID).'</a></strong></p></li>';
}
$retval .= '</ul></div>';
return $retval;
}

add_shortcode('myauthorbox', 'all_authors');
share|improve this question
    
Where do you initiate the function? Is it loaded in the theme setup step or after or before? –  petermolnar Apr 4 '11 at 7:05
add comment

1 Answer

up vote 1 down vote accepted

the_author_meta() is display function, it echoes the result to screen right where it's called. To concatenate with string you need to use function that returns result - get_the_author_meta().

share|improve this answer
    
Thank you so much! –  Gregg Franklin Apr 4 '11 at 13:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.