Active PHP in blog entries
-
Is there any way to have active PHP executing in a blog entry?
I’m trying to get a random image to load using PHP’s mt_rand function. I have 19 images in a folder named about1.jpg through about19.jpg. I’m trying to bring up the random image with the following code:
<img src="about<?php echo mt_rand(1, 19); ?>.jpg" />But WordPress keeps on re-writing the code like this:
<img src="about%3C?php echo mt_rand(1, 19); ?>.jpg" />I use the same approach all over my site in the include files to load random header images, etc., so it’s a bit of a drag I can’t get it in the entries, especially since I’m planning on writing an entry about random PHP tricks with active examples.
Does anyone have a workaround?
The topic ‘Active PHP in blog entries’ is closed to new replies.