Title: Execute PHP in AddFunc Head &amp; Footer Code
Last modified: November 13, 2016

---

# Execute PHP in AddFunc Head & Footer Code

 *  Resolved [mlaw93](https://wordpress.org/support/users/mlaw93/)
 * (@mlaw93)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/execute-php-in-addfunc-head-footer-code/)
 * Is there a way to enable php execution in AddFunc Head & Footer Code?
    I need
   some dynamic jQuery in the footer.

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

 *  Thread Starter [mlaw93](https://wordpress.org/support/users/mlaw93/)
 * (@mlaw93)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/execute-php-in-addfunc-head-footer-code/#post-8429033)
 * I found a way, although now I have to be careful with upgrades – I added a method
   called aFhfc_execute_php. I call it before returning the final html.
 *     ```
       /*
       F R O N T E N D O U T P U T
       ===============================
       Outputs the head and footer code for individual posts
       */
       function aFhfc_execute_php($html){
       if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html);
       $html=ob_get_contents();
       ob_end_clean();
       }
       return $html;
       }
       function aFhfc_head_output( $post ) {
       $aFhfc_head_code = get_post_meta( get_the_ID(), 'aFhfc_head_code', true );
       echo aFhfc_execute_php($aFhfc_head_code)."\n";
       }
       add_action('wp_head', 'aFhfc_head_output');
       function aFhfc_footer_output( $post ) {
       $aFhfc_footer_code = get_post_meta( get_the_ID(), 'aFhfc_footer_code', true );
       echo aFhfc_execute_php($aFhfc_footer_code)."\n";
       }
       add_action('wp_footer', 'aFhfc_footer_output');
       ```
   
 *  Plugin Author [Joe Rhoney](https://wordpress.org/support/users/joerhoney/)
 * (@joerhoney)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/execute-php-in-addfunc-head-footer-code/#post-8652154)
 * Well done! Yeah, there is no way as is, so an implementation such as this one
   would be necessary. If you want to avoid update notifications so you don’t accidentally
   update it, you can do this:
    1. Backup the code you have in all of the AddFunc Head & Footer Code fields (in
       a text document), don’t forget individual Page/Post meta fields
    2. Rename the plugin directory (whatever you want, but no spaces)
    3. Rename the main plugin file (addfunc-head-footer-code.php in this case), giving
       it the exact same name you gave the directory
    4. Paste your code back into their respective fields
 * This basic procedure works with all plugins and you will no longer see update
   notifications. However, some plugins may not function properly afterwards.

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

The topic ‘Execute PHP in AddFunc Head & Footer Code’ is closed to new replies.

 * ![](https://ps.w.org/addfunc-head-footer-code/assets/icon.svg?rev=1245441)
 * [AddFunc Head & Footer Code](https://wordpress.org/plugins/addfunc-head-footer-code/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/addfunc-head-footer-code/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/addfunc-head-footer-code/)
 * [Active Topics](https://wordpress.org/support/plugin/addfunc-head-footer-code/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/addfunc-head-footer-code/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/addfunc-head-footer-code/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Joe Rhoney](https://wordpress.org/support/users/joerhoney/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/execute-php-in-addfunc-head-footer-code/#post-8652154)
 * Status: resolved