I'm using the twitter block in tumblr which displays the latest tweets from my twitter feed. Right now it displays the last 20 tweets but I want it to only show the last 5 tweets. anyone have any idea how I can do that?
the code I'm using right now is below. I tried changing the .length variable to 5 in the loop, but that didn't do anything:
{block:Twitter}
<div id="twitter" style="display:none;">
<h3><a href="http://twitter.com/{TwitterUsername}">Latest Tweets</a></h3>
<div id="tweets"></div>
</div>
<script type="text/javascript">
function recent_tweets(data) {
for (i=0; i<data.length; i++) {
document.getElementById("tweets").innerHTML =
document.getElementById("tweets").innerHTML +
'<a href="http://twitter.com/{TwitterUsername}/status/' +
(data[i].id_str ? data[i].id_str : data[i].id) +
'"><div class="content">' + data[i].text +
'</div></a>';
}
document.getElementById("twitter").style.display = 'block';
}
</script>
{/block:Twitter}
Not sure how you changed the variable, but this should work:
<script type="text/javascript">
function recent_tweets(data) {
for (i=0; i<5; i++) {
document.getElementById("tweets").innerHTML =
document.getElementById("tweets").innerHTML +
'<a href="http://twitter.com/{TwitterUsername}/status/' +
(data[i].id_str ? data[i].id_str : data[i].id) +
'"><div class="content">' + data[i].text +
'</div></a>';
}
document.getElementById("twitter").style.display = 'block';
}
</script>
You'll also need to remove the 2nd recent_tweets
function that your are calling. The one you change to be i<5
is being overwritten by another one being called later in your theme file.