Getting “The Author” When you’re not in “the Loop”
-
Okay, so my saga to put the author of a post into a custom RSS feed continues. I have finally figured out that it has something to with “the loop”.
Since the RSS feed does not contain “the loop”, then my code fails.
Here’s what I’m trying to use:
<author><?php the_author(); ?></author>
This just spits out nothing. The code for the “item” part of my RSS feed looks like this, which as far as I can tell looks like a “loop” to me, but it’s not the wordpress “loop”. How can I pull the author name and put it in here?
<?php foreach ($posts as $post) { ?> <item> <title><?php echo get_the_title($post->ID); ?></title> <link><?php echo get_permalink($post->ID); ?></link> <author>****** WHAT GOES HERE? ******</author> <description><?php echo '<![CDATA['.apply_filters('the_content', $post->post_content).'<br /><br /><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.']]>'; ?></description> <pubDate><?php triple_rss_date( strtotime($post->post_date_gmt) ); ?></pubDate> <guid><?php echo get_permalink($post->ID); ?></guid> </item> <?php } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Getting “The Author” When you’re not in “the Loop”’ is closed to new replies.