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:
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>");
} ?>