I’ve seen that you’re a fan of Code Snippets, but that only works for code that should work as if it were in a functions.php file. Do you know of a way (plugin, black magic, etc) which will allow php in pages/posts that works well within GeneratePress?
Basically I want to create a way to calculate years since a date. Many of my clients have statements on their sites like “A family owned business for 25 years”. The idea is to automate updating this date.
The code (if it worked within a page) would look something like this for a business which started Feb 11, 1981.
We have been in business for <?php $bizstart=new DateTime("1981-02-11");$today=new DateTime();$interval=$today->diff($bizstart);echo $interval->format('%y '); ?>years.
Thanks Leo. I messed around with making my own shortcode last night, but I think I got the syntax wrong. It kept spacing things out strangely. I’ll read the docs and give it another whirl tonight. Good to know I’m on the right track. Will update progress, thanks!