i have created this PHP function in wordpress:
function show_posts_archive($output = OBJECT, $post_type = 'post' ) {
global $wpdb;
$page = $wpdb->get_var(
$wpdb->prepare(
"SELECT * FROM $wpdb->posts
WHERE post_type= %s
group by MONTH(post_date) ",
$post_type )
);
if ( $page )
return get_post( $page, $output );
return null;
}
how can i display the blog archives (like on a wordpress template) on my external website?
I’m not sure if you want to display the whole post or just the titles and links of the archive/old items.
But using RSS is probably your best bet (depending on what was used to create the external website)
With permalinks:
http://example.com/2014/01/feed
and Without permalinks:
http://example.com/?m=200808&feed=rss2 (personally haven’t tested)
You can then parse the RSS and display the information you require, there are quite a few out there, Zend_Feed / ZendFeed (Zend Framework2) / SimplePie, all depends on your needs.
how can i display the blog archives (like on a wordpress template) on my external website?
Return the posts in an XML format – this would create an RSS – and then get a plugin on your external site to fetch the XML and render them as “posts”. This would be the most easiest and logical way, IMO.
Probably from your external template you will need to point to the wordpress database. that way you can fetch the details in a query and output it in whichever format you desire.
say August 2013 | September 2013 | October 2013….
I suggest keep database common. Win win situation. Manage both the views independentally