Originally for my post on the Body Mass Index (BMI), I wanted to include a BMI calculator directly in the post. I found a WordPress plugin, PHP Code for Posts that allowed me to use PHP code in the post and coded the calculator. Unfortunately, when I tried to put the calculator on the page, I ran into an issue with how the variables are passed from the form to the function that handles the calculations. The code works on it’s own, but embedded in a post it fails. I ended up making a link to the URL where I had tested the calculator. I’m hoping to find a better solution in the future.
Here’s the code, in case you’re intersted (formatted with Preserve Code Formatting). Normally, I’d pull the style sheet and HTML into their own files, but for the purposes of displaying the code I have them all together.
Body Mass Index (BMI) Calculator for Adults
'; function bmiForm() { echo '