• OK so I would like to pull in RSS feeds to post templates on my site.

    Ideally, I’d like to specify the feed itself as a custom field – I’ve got the code I want for magpie, but where I’m stuck is outputting the custom field as the variable for the Magpie code.

    Could anyone offer any advice?

    This is the code I’m working with:

    <div class="twitter-feed">
    <?php
    require_once('magpierss/rss_fetch.inc');
    
    $num_items = 5;
    $rss = fetch_rss( 'FEED URL HERE' );
    
    if($rss) {
      $items = array_slice($rss->items, 0, $num_items);
    
      echo "<ul>";
      foreach ($items as $item) {
        $href = $item['link'];
        $title = $item['title'];
        $title = str_replace("joshhostels: ", "", "$title");  // see below
        echo "<li><a href=\"$href\" rel=\"nofollow\">$title</a></li>";
      }
      echo "</ul>";
    } else {
      echo "<p>Feed currently updating.  Please check back soon.</p>";
    }
    ?>
    </div>

    So where it says ‘FEED URL HERE’, I need to output the custom field – Could anyone help?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter olikid

    (@olikid)

    I know bumping isn’t the done thing here, but have I missed something with this forum? The majority of the time I ask questions on here they go completely unanswered – am I posting in the wrong place or formatting the posts incorrectly?

    I think what I’m asking for is pretty straightforward? Honestly, any help you can give would be so appreciated – and if I’ve posted something wrong let me know and I’ll get it fixed up.

    Thread Starter olikid

    (@olikid)

    OK so I think this is pretty much it – just not working yet, but I think the login is right?

    <div class="twitter-feed">
    <?php
    
    require_once('magpierss/rss_fetch.inc');
    
    $num_items = 5;
    $rss = get_post_custom_values("CUSTOMFIELD"); 
    
    if($rss) {
      $items = array_slice($rss->items, 0, $num_items);
    
      echo "<ul>";
      foreach ($items as $item) {
        $href = $item['link'];
        $title = $item['title'];
        $title = str_replace("foo: ", "", "$title");  // see below
        echo "<li><a href=\"$href\" rel=\"nofollow\">$title</a></li>";
      }
      echo "</ul>";
    } else {
      echo "<p>Feed currently updating.  Please check back soon.</p>";
    }
    ?>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using Custom Field as Variable in MagpieRSS’ is closed to new replies.