Before you call get popular posts, connect to Mint-DB: ------------------------------------------------------ < ?php $mysql = mysql_connect('Mint-DB-Hostname', 'Mint-DB-User', 'Mint-DB-Password') or die('Could not connect to database: ' . mysql_error()); ?> < ?php mysql_select_db('Mint-DB-Name') or die('Error selecting database'); ?> The call: --------- < ?php getPopularPosts(...parameters...); ?> After the call has finished, connect back to WP-DB: --------------------------------------------------- < ?php mysql_close($mysql); ?> < ?php $mysql = mysql_connect('WP-DB-Hostname', 'WP-DB-User', 'WP-DB-Password') or die('Could not connect to database: ' . mysql_error()); ?> < ?php mysql_select_db('WP-DB-Name') or die('Error selecting database'); ?>