Basically, just read this post Timeline Archive View For WordPress and then do some improvement by following my article.
First, we don't want to generate a XML file every time, so make it generate one XML file and let the Timeline uses that XML file. Here is the code, put this code in the wordpress root, this is the modified version of the original one from Crickets Chirping:
if (empty($wp)) {
require_once('wp-config.php');
wp('feed=atom');
}
$more = 1;
$data = '<data>';
$my_query = new WP_Query('showposts=50');//change the number for showposts
//to how many post you want to show on the timeline.
while ($my_query->have_posts()){
$my_query->the_post();
$data .= '<event
start="';
ob_start();
$data .= get_post_time('M d Y H:i:s \G\M\T', true);
ob_end_clean();
$data .= '"
isDuration="false"
title="';
ob_start();
the_title_rss();
$data .= ob_get_contents();
ob_end_clean();
$data .= '"
link="';
ob_start();
permalink_single_rss();
$data .= ob_get_contents();
ob_end_clean();
$data .= '">';
ob_start();
the_excerpt_rss(40, 1);
$cool = ob_get_contents();
ob_end_clean();
$data .= str_replace('>','>',str_replace('<', '<',$cool));
$data .= '</event>';
}
$data .= '</data>';
$fname = "timeline-xml.xml";//name of the file
$fhandle = fopen($fname,"w");
fwrite($fhandle,$data);
fclose($fhandle);
And that generate a XML file in the server. Make the Timeline API link to that XML file
Now we just want to run it every one hour(or what ever you think it's fit), do that by configure the cron job or using a fake cron script like WP-cron.
Recent comments
11 hours 38 min ago
20 hours 51 min ago
2 days 6 hours ago
3 days 10 hours ago
3 days 14 hours ago
3 days 14 hours ago
3 days 14 hours ago
4 days 6 hours ago
4 days 7 hours ago
4 days 9 hours ago