Top
Home

tumblr list xml

Put the links to the last 20 Tumblr posts on a site.



<h1>Last 20 Posts on YOURTUMLRNAME.tumblr.com</h1>
<ol style="text-transform:capitalize">
<?php
echo "";
$request_url = "http://YOURTUMLRNAME.tumblr.com/api/read"; //get xml file
$xml = simplexml_load_file($request_url); //load it
$posts = $xml->xpath("/tumblr/posts/post");
foreach ($posts as $post) {
$linktext = $post->{'link-text'}; //load post title into $title
$body = $post->{'regular-body'}; //load post body into $post
$link = $post['url-with-slug']; //load url of blog post into $link
$small_post = substr($body,0,300); //shorten post body to 300 characters
echo // spit that baby out with some stylish html
' <li>'
. '<a href="'.$link.'">'.$linktext.'</a>
</li>
';
}
?>
</ol>