An Adventure in arbitrary PHP in WordPress.
posted August 6th, 2009 to Code, Server SideOne of the finishing touches I wanted to add to this blog theme was a copyright
statement in roman numerals. Inserting arbitrary PHP into WordPress isn’t as straightforward as it should be, so I’ve outlined instructions below:
1. Edit the functions.php file of your theme to add the following code (courtesy Pradeep S).
// A function to return the Roman Numeral, given an integer function numberToRoman($num){ // use int value $n = intval($num); $result = ''; $lookup = array( 'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1 ); foreach ($lookup as $roman => $value){ $matches = intval($n / $value); $result .= str_repeat($roman, $matches); $n = $n % $value; } return $result; }
2. Edit the footer.php file in the theme to add a reference to the new function in the copyright block.
<div id="footer" class="grid_12"> <p>© <?php echo numberToRoman(date("Y")); ?></p> </div> <?php wp_footer(); ?> </body>
3. You’re done!









Fantastic post, I did not thought it would be so great when I saw your url!