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.

This is probably a super simple question.

But how do I echo the ID of a user on author.php?

I've tried

the_author_meta('ID')

But it didn't seem to want to work. I want to echo it at the end of a URL, for example;

http:///www.domain.com/author/sampleauthor-id

Obviously, where "id" is that particular author's ID

Any ideas?

share|improve this question
    
Not the permalinks, its for a modified version of the UserPhoto plugin. I want to hardcode a particular image link into author.php and as each user's images are appeneded with their author ID I need to include that in the link –  Dean Elliott Dec 1 '11 at 10:54

1 Answer 1

up vote 4 down vote accepted

Try this code.

$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
echo $author->ID;
share|improve this answer
    
This gives me a 500 internal server error –  Dean Elliott Dec 1 '11 at 11:01
    
Are you sure it is because of the above code.. could I have a look at your author.php? –  Joshua Abenazer Dec 1 '11 at 11:05
    
$author = get_user_by( 'slug', get_query_var( 'author_name' ) ); gave no problems, it was the echo author->ID; that caused the error for some reason –  Dean Elliott Dec 1 '11 at 11:07
    
Oops there is a typo.. its echo $author->ID... notice the '$'. Updated the answer. –  Joshua Abenazer Dec 1 '11 at 11:08
1  
Both of you missed a dollar sign. echo $author->ID; –  Johannes Pille Dec 1 '11 at 11:09

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.