Why execute php from a Wordpress Mu post
In the previous post I mentioned some issues with injecting php into a Wordpress Mu blog post. Some people probably don’t understand why would you want to execute php code from inside a blog post. Well the most obvious answer now that I’ve done some research and what seems to be the primary concern of Jim Groom and the many followers of the issue is the ability to configure and display dynamically aggregated RSS feeds for posts as well as doing some fancy stuff in the widgets. I can imagine the possibilities are endless.
But the obvious reason isn’t what initially got me started on the search to execute php from inside a post or page. I want to be able to add a set of custom fields to certain categories of posts and then execute sql commands against them. For example on an outdoor photography blog, for all posts in the ‘Trip Report’ category I might add some fields called ‘location’, ‘mileage’, ‘meals’, ‘fuel’, ‘other_expenses’. Then I could have a page called ‘Trip Expenses’ that would query all the Trip Report posts and display the results in tables, charts, and/or graphs. A Wordpress page with embedded php could create fancy charts and graphs laid out however you like, like the Quickbooks dashboard, for example. The page would re-calculate every time it’s opened. How sweet is that?
Another example:Â On a blog chronicling a fitness program I could add custom fields to the ‘Daily Workout’ posts like ‘exercise_type’, ‘total_distance’, ‘total_time’, ‘5k_time’, ‘peak_heart_rate’, ‘two_min_recovery_heart_rate’, ‘etc…’. Then I could have a Page called ‘Treadmill Progress Report’ or ‘Bench Press Progress Report’ that spits out graphs based on the fields in all the Daily Workout posts.
Using this technique you could easily build simple database applications within a wordpress blog. You could also build large, complex applications like this but that would be silly, wouldn’t it?
