If you need to execute PHP “on the fly”, you have problems in how your site is designed. If there are things that need doing repeatedly, then shortcodes are a good idea. Shortcodes can also be executed from inside a template with the do_shortcode() function.
Writing a plugin to hold your set of custom shortcodes is trivial. If you want to go that route, I can share a sample with you.
Thread Starter
bbhank
(@bbhank)
Not sure of what you mean with on the fly but each page shows the information for that page, that business, by ID number. When you go to the page it is for one particular business. Data for each business changes freely.
I was using exec-php without problem until it ceased to work. Now none of the shortcodes work. Presently the php is in Custom ShortCode Creator, which also shows its on the way out. Hasn’t been updated in a long time. No word from the producer. Its shortcodes are in the main template of a child theme.
I also tried putting the actual php in place of the shortcodes and without exec-php they didn’t work that way either. Before the loss of exec-php neither was a problem. I could use either shortcode or php wherever I wanted.
-
This reply was modified 7 years, 9 months ago by
bbhank.
Where is the data for the business stored? You could write your own shortcode(s) to retrieve and display it.
Thread Starter
bbhank
(@bbhank)
The data is in 3 separate tables in the database. The queries and formatting how its displayed has all been done and worked from the time the site was built. When the php was working, you would select a business by way of the dropdown. That takes you to the page for that business and shows data from a table that has stuff about the business and a table that has events from a calendar. It also has a map that gets its location from the database.
If you have the PHP you can either put it directly in templates or create shortcodes to hold it and add them to content.
Thread Starter
bbhank
(@bbhank)
That’s what I’ve been doing.
Not being a programmer, I used Custom Shortcode Creator plugin to house the php. It all worked until recently. I’m running the site in debug mode and getting no errors at all. Got very little to go on. I’ve tried putting the code directly into the template but it doesn’t work and gives no error message that way either.
Thread Starter
bbhank
(@bbhank)
Rewrote a lot of the queries. I’m thinking it was old. It’s possible the host upgraded their version of MySQL to MySQLi. Something about May 26. My code was written with MySQL several years ago.