I have 2 authors and an admin on my blog.
I am using the following code in my contributors.php
function contributors() {
global $wpdb;
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
foreach($authors as $author) {
echo the_author_image($author->ID);
echo the_author_meta('display_name', $author->ID) . '</br>' ;
echo the_author_meta('user_url', $author->ID) . '</br>';
echo the_author_meta('description', $author->ID) . '</br>' ;
echo the_author_meta('user_email', $author->ID) . '</br></br>' ;
}
}
contributors();
It’s printing all authors’ and admin’s photo, name, description and email perfectly.
but it not printing the user link correctly.
- for admin or user ID 1 it’s printing the blog URL
- for 1st author or user ID 2, it’s printing the correct URL.
- for 2nd author or user ID 3, it’s printing nothing.
what is the problem? how can I solve this?
Have you checked the database for User’s url. Maybe that’s what they used for registering.
What about this scenario –
You should fist check their url from the database. It resides in
wp_users
table(I am assuming that you have used the table prefixwp_
).EDIT:
the_author_posts_link()
andthe_author_meta('user_url',$userID)
have different functionality.the_author_posts_link()
display displays a link to all posts by an author.the_author_meta('user_url',$userID)
displays their homepage url.So, these are two different things. I think your best bet is to use the following to get what you are trying to achevie instead of
the_author_meta('user_url', $userID)
. You can’t also usethe_author_posts_link
as it takes no argument and have to be used inside The Loop: