Title: path to php code?
Last modified: January 22, 2017

---

# path to php code?

 *  Resolved [bikeman123](https://wordpress.org/support/users/bikeman123/)
 * (@bikeman123)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/path-to-php-code/)
 * I am trying to include php code with a php include
    <?php include(‘inc/myscript.
   php’) ?> but I am getting ‘failed to open stream: No such file or directory..’
   the ‘inc’ folder is within my theme. I’ve tried all sorts of paths but I can’t
   seem to get to inc/myscript.php Do I need to include the theme path? I’ve tried
   <?php include bloginfo( ‘template_url’) + ‘/inc/myscript.php’ ?>
    -  This topic was modified 9 years, 2 months ago by [bikeman123](https://wordpress.org/support/users/bikeman123/).
    -  This topic was modified 9 years, 2 months ago by [bikeman123](https://wordpress.org/support/users/bikeman123/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [9 years, 2 months ago](https://wordpress.org/support/topic/path-to-php-code/#post-8698643)
 * The PHP code widget executes any code in it from inside the widget itself, so
   the “current” directory will be the /plugins/php-code-widget directory, not your
   theme’s directory.
 * To include files from your theme, you need to specify the full path to those 
   files. A partial path will not do. You can get the path to the theme directory
   like so:
 * `include get_template_directory() . '/inc/myscript.php';`
    -  This reply was modified 9 years, 2 months ago by [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/).

Viewing 1 replies (of 1 total)

The topic ‘path to php code?’ is closed to new replies.

 * ![](https://ps.w.org/php-code-widget/assets/icon.svg?rev=992095)
 * [PHP Code Widget](https://wordpress.org/plugins/php-code-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/php-code-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/php-code-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/php-code-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/php-code-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/php-code-widget/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/path-to-php-code/#post-8698643)
 * Status: resolved