• Resolved bikeman123

    (@bikeman123)


    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 8 years, 2 months ago by bikeman123.
    • This topic was modified 8 years, 2 months ago by bikeman123.
Viewing 1 replies (of 1 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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';

Viewing 1 replies (of 1 total)
  • The topic ‘path to php code?’ is closed to new replies.