Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Showing Tumblr data for a News Manager
#1
Change the yournamehere to your tumblr name this in your theme, it's using the same CSS tags as the simple news manager(didn't feel like modifying my css, sue me), you can pull the amount of posts you want with the last num:

Quote:<?php

function tumblr()
{
$feed = simplexml_load_file('http://yournamehere.tumblr.com/api/read?type=post&start=0&num=4');
$posts = $feed->xpath("/tumblr/posts/post");
foreach ($posts as $post) {
echo '<div class="article">';
echo "<br/>";
echo '<h3 class="article_title">'.$post->{'regular-title'}. '</h3>';
echo '<p class="article_date">' .$post['date'].'</p>';
echo $post->{'regular-body'};
echo "<br/>";
echo '<a href="'.$post['url']. '">Read More</a>';
echo "</div>";
}
}
?>
<? tumblr() ?>

I'll try to turn it into a plugin, if I can figure out how. I'm not gods gift to PHP and it took me like 2 days and lots of time in the PHP manuals figuring out xpath and foreach.
Reply


Messages In This Thread
Showing Tumblr data for a News Manager - by samrocksc - 2011-02-07, 10:32:57



Users browsing this thread: 1 Guest(s)