Get Author of wordpress blog

  • Thread starter Thread starter ~J~
  • Start date Start date

~J~

~J~

Soldato
Joined
20 Oct 2003
Posts
7,558
Location
London
I've worked out that:

echo get_permalink($np->ID);

will get the permalink of a post.

However I want to get the author and date/time of the post too.

Trying to use a bit of common sense, I tried...

echo get_author($np->ID);

and

echo get_postdate($np->ID);

But I get an error saying get_author and/or get_postdate are undefined functions.

Anyone know what the correct method is?

If it helps, my entire code is:

<?php
$how_many=5; //How many posts do you want to show
require_once("wp-config.php"); // Change this for your path to wp-config.php file ?>
<?
$news=$wpdb->get_results("SELECT `ID`,`post_title` FROM $wpdb->posts
WHERE `post_status`= \"publish\" AND `post_type`= \"post\" ORDER BY 'ID' DESC LIMIT ".$how_many);
foreach($news as $np){
print ("<h5>");
echo $np->post_title;
print ("</h5>");
print ("<p><a href=\"");
echo get_permalink($np->ID);
print ("\">Read more…</a></p>");
print ("<p><em class='date'>Posted by ");
echo get_author($np->ID);
print ("on ");
print ("</em></p>");
} ?>
 
It's not

Code:
get_the_author_ID($np->ID)

by any chance is it? That just came into my mind as I read the title. Could be utterly wrong, so apologies if so!

Jon
 
Last edited:
GeForce said:
It's not

Code:
get_the_author_ID($np->ID)

by any chance is it? That just came into my mind as I read the title. Could be utterly wrong, so apologies if so!

Jon

Well it is, kinda.

What that returns is a '1' which is the author ID. What I want is the actual author name, based on the author ID of the post.

Cheers anyway.

*edit* get_the_author($np->ID) works perfect!! :)
 
Back
Top Bottom