I am using the code from yoast https://yoast.com/tag/rss/ and have modified it a bit to show the featured image which it is doing. I am trying to figure out how to show the Author now

I tried adding int
but that does not work. What am I missing to get this to show?

Template Name: Custom Feed

$numposts = 10;

function acustom_rss_date( $timestamp = null ) {
$timestamp = ($timestamp==null) ? time() : $timestamp;
echo date(DATE_RSS, $timestamp);

function acustom_rss_text_limit($string, $length, $replacer = '...') { 
$string = strip_tags($string);
if(strlen($string) > $length) 
return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches)  ? $matches[1] : substr($string, 0, $length)) . $replacer;   
return $string; 

$posts = query_posts('showposts='.$numposts);

$lastpost = $numposts - 1;

header("Content-Type: application/rss+xml; charset=UTF-8");
echo '<?xml version="1.0"?>';
?><rss version="2.0" xmlns:media="http://search.yahoo.com/mrss">
<title>Test E-mail Update</title>
<description>The latest posts from test.com</description>
<pubDate><?php acustom_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></pubDate>
<lastBuildDate><?php acustom_rss_date( strtotime($ps[$lastpost]- >post_date_gmt) ); ?></lastBuildDate>
<?php foreach ($posts as $post) { ?>
<title><?php echo get_the_title($post->ID); ?></title>
<link><?php echo get_permalink($post->ID); ?></link>
 <?php if(get_the_post_thumbnail()): ?>
<media:content url="<?php $image =   wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail'); echo  $image[0]; ?>" medium="image" />
<?php endif; ?>


<?php echo '<![CDATA['.acustom_rss_text_limit($post->post_content, 500).'<br/><br/><a href="'.get_permalink($post->ID).'"> Continue Reading. </a>'.']]>';  ?>


<dc:creator><?php echo get_the_author_meta( 'display_name', $post->post_author ); ?>

<pubDate><?php acustom_rss_date( strtotime($post->post_date_gmt) ); ?></pubDate>
<guid><?php echo get_permalink($post->ID); ?></guid>
<?php } ?>
  • I suggest you append author name to post content. ... by author
    – MahdiY
    Commented Mar 31, 2017 at 19:44
  • Not sure I fallow how you would this?
    – Sdesign
    Commented Mar 31, 2017 at 19:47

1 Answer 1


Try it:

<?php echo get_the_author_meta( 'display_name', $post->post_author ); ?>

You can use the_author function in wordpress standard loop, Not foreach. to set global author information you should use the_post function. but in foreach, you can use get_the_author_meta instead of the_author to pass author id $post->post_author.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.