Hi there,
I am currently using:
<?php
global $wp_query;
$curauth = $wp_query->get_queried_object();
?>
<p>This is <?php echo $curauth->ID; ?>'s page</p>
<p>This is <?php echo $curauth->display_name; ?>'s page</p>
<p>This is <?php echo $curauth->first_name; ?>'s page</p>
<p>This is <?php echo $curauth->last_name; ?>'s page</p>
<p>This is <?php echo $curauth->user_nicename; ?>'s page</p>
but it wont pick anything up apart from ID. I need it to show the user's username in the template.
not even -> this works <?php the_author(); ?>
I do it this way
$user_info = get_userdata($user_id);
$author_nice=$user_info->display_name;
$author_nick=$user_info->nickname;
$author_first=$user_info->first_name;
$author_last=$user_info->last_name;
and you can get the user_id of the post from the post data:
$post = get_post($post_id);
$user_id=$post->post_author;
Thanks Steve,
I tried adding this to my page:
<?php
$user_info = get_userdata($user_id);
$author_nice=$user_info->display_name;
$author_nick=$user_info->nickname;
$author_first=$user_info->first_name;
$author_last=$user_info->last_name;
?>
But no username displays. Is there something i am writing wrong?
you're not echoing the results.
I dont understand it:
<?php
$user_info = get_userdata($user_id);
$author_nice=$user_info->display_name;
$author_nick=$user_info->nickname;
$author_first=$user_info->first_name;
$author_last=$user_info->last_name;
?>
Test:<?php echo "$author_nice" ?>
Is the user_id set ?
Did you do:
$post = get_post($post_id);
$user_id=$post->post_author;
first?
Thats perfect, thanks Steve
.....
<?php
$post = get_post($post_id);
$user_id=$post->post_author;
?>
<?php
$author_first=$user_info->first_name;
?>
Result:<?php echo "$author_first" ?>
........