Getting WP-Cache and WPAudioScrobbler to play together
April 7th, 2007 | Posted in Development, Wordpress | 1 Comments
One way to speed your wordpress site up is to make use of WP-Cache. One of the cool features of this plugin is the ability to dynamically load page elements. I wanted to be able to continue to load my Last.FM play list using WPAudioScrobbler whilst having the rest of the page load from a cached version on the server.
To achieve this you make use of two special tags, mclude and mfunc.
Unfortunately the documentation does not make it clear how to go about using the tags correctly, so through carefully analysing the code, deciphering the regular expression and a large chunk of trial and error I managed to get both WPAudioScrobbler and WP-Cache to co-exist.
From within the template displaying your Last.FM play list, replace:
-
wpaudioscrobbler();
with
-
< !–mclude wp-content/plugins/wpaudioscrobbler/wpaudioscrobbler.php–>
-
< ?php include_once(ABSPATH . ‘/wp-content/plugins/wpaudioscrobbler/wpaudioscrobbler.php’); ?>
-
< !–/mclude–>
-
< !–mfunc wpaudioscrobbler()–>
-
< ?php wpaudioscrobbler(); ?>
-
< !–/mfunc–>
Note: for some unexplained reason, wordpress seems to replace a double hyphen with a minus symbol. If you copy and paste, remember to swap them back and remove the space after the opening < tag.












One note to add that might help people is that the first part:
uses the path that is relative to wherever your WordPress core files are. So always start this with ‘wp-content’ or ‘wp-admin’ with no beginning forward-slash.