• I’ve managed to pull the title of post via RSS feed using the script below.

    <?php include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss('http://example.com/?feed=rss'); $maxitems = 1; $items = array_slice($rss->items, 0, $maxitems); ?>
    <?php foreach ( $items as $item ) : ?>
    <?php echo $item['title']; ?>
    <?php endforeach; ?>

    How do i pull the author of that post?

    <?php echo $item['author']; ?>

    doesnt work for me, maybe it’s wrong. What is the correct bits of code i need to add or replace? Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • First of all, you don’t need to have ‘<?php’ and ‘?>’ on each line. You can just write:

    <?php
    include_once(ABSPATH . WPINC . '/rss.php');
    $rss = fetch_rss('http://example.com/?feed=rss'); $maxitems = 1; $items = array_slice($rss->items, 0, $maxitems);
    foreach ( $items as $item ) :
      echo $item['title'];
    endforeach;
    ?>

    To find out where the author information is, write print_r($items) to see how the array is built and replace $item[‘author’] with what you need.

    Thread Starter elphi

    (@elphi)

    I need to write ‘<?php’ and ‘?>’ on each line once this is use on the actual page. I use print_r($items) but it makes me more confuse. Sorry for being “noobish” 😐

    I still can’t figure out how to pull the author of each post..

    Paste here what you get from print_r.

    I need to write ‘<?php’ and ‘?>’ on each line once this is use on the actual page.

    No, you don’t if the code is in one block, but this isn’t very important.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Import RSS Feed Author’ is closed to new replies.