For certain purposes, it may be useful for you to include PHP snippets inside your WordPress posts. (If you try, you’ll find things will likely not work properly.) Well… Sören Weber created the plugin Exec-PHP exactly for this purpose.
Below is a banner from the Early To Rise affiliate program. I’ve written a snippet of PHP that chooses which banner to display based on the remainder left over when dividing the current server time (in seconds) by 18 (that is, there are 18 different banners that can be displayed — try reloading the page several times to see what I mean):
Being able to execute PHP code included in your post can be very useful. In the example above, I’ve used it to display different banner ads. By randomizing the display of two different banner ads, you can test which results in more conversions for you. In any case, yes, you CAN run PHP code in your WordPress posts by using the Exec-PHP plugin. This allows WordPress to offer similar functionality in terms of the content of blog post entries as Drupal (which only needs permissions to be configured to allow a user this ability). In any case — this is nice — with this plugin, WordPress becomes even more powerful than it already is



Hi…The Exec-PHP Plugin is not working any more in the latest versions of wordpress (2.9), do you know if there is a workaround?
Thanks.
Hi, Phil!
If you reload the this page a few times, you’ll see that the little banner-ad switching script is working (you should see a different banner from time to time). You might double check that your WordPress settings didn’t change when you upgraded. In particular, under Writing Settings make sure that the “WordPress should correct invalidly nested XHTML automatically” option is not selected as this will mess with your PHP scripts embedded in your posts. I hope you get things working on your site again.
Wishing you success, health, and happiness!
Your friend,
M.E.B.
Knobb Music Blog