• Resolved bbhank

    (@bbhank)


    Used exec-php for years to execute php anywhere and everywhere, in my site, including from within the themes and page templates. Exec-php is extinct (developer hasn’t updated the plugin in years), and lately, causes fatal error when activated and will not load. Custom ShortCode Creator is also abandoned by developer and no longer executes php in its shortcodes.

    Need to still be able to freely execute php from inside theme and page template(s). Allow php and Insert_php works for pages and widgets but not for theme and templates.

    Looking for plugin or way to be able to execute php anywhere in themes and templates as well as pages.

    • This topic was modified 6 years, 8 months ago by bbhank.
    • This topic was modified 6 years, 8 months ago by bbhank.
    • This topic was modified 6 years, 8 months ago by bbhank.
    • This topic was modified 6 years, 8 months ago by bbhank.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    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 6 years, 8 months ago by bbhank.
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    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.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Execute custom php in template and theme’ is closed to new replies.