Title: Execute custom php in template and theme
Last modified: July 28, 2018

---

# Execute custom php in template and theme

 *  Resolved [bbhank](https://wordpress.org/support/users/bbhank/)
 * (@bbhank)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/)
 * 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 7 years, 9 months ago by [bbhank](https://wordpress.org/support/users/bbhank/).
    -  This topic was modified 7 years, 9 months ago by [bbhank](https://wordpress.org/support/users/bbhank/).
    -  This topic was modified 7 years, 9 months ago by [bbhank](https://wordpress.org/support/users/bbhank/).
    -  This topic was modified 7 years, 9 months ago by [bbhank](https://wordpress.org/support/users/bbhank/).

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10534869)
 * 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.
    -  This reply was modified 7 years, 9 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [bbhank](https://wordpress.org/support/users/bbhank/)
 * (@bbhank)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10534948)
 * 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](https://wordpress.org/support/users/bbhank/).
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10534986)
 * Where is the data for the business stored? You could write your own shortcode(
   s) to retrieve and display it.
 *  Thread Starter [bbhank](https://wordpress.org/support/users/bbhank/)
 * (@bbhank)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10535027)
 * 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)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10535035)
 * 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](https://wordpress.org/support/users/bbhank/)
 * (@bbhank)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10535044)
 * 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](https://wordpress.org/support/users/bbhank/)
 * (@bbhank)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10542162)
 * 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.

## Tags

 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [old code](https://wordpress.org/support/topic-tag/old-code/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [bbhank](https://wordpress.org/support/users/bbhank/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/execute-custom-php-in-template-and-theme/#post-10542162)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
