• Resolved nimbus3000

    (@nimbus3000)


    Hi everyone,

    I am new to wordpress and PHP and trying to find my way around.
    I have placed a file with a single function in the base folder (C:\xampp\htdocs\wordpress).
    within the [insertphp] tags, I have include ‘<\name of the file>’. I have also tried to include the entire path to the file, but that doesnt work either.
    I am getting the following error: Warning: include(1): failed to open stream: No such file or directory in C:\xampp\htdocs\wordpress\wp-content\plugins\insert-php\insert_php.php

    Can someone please help me.

    https://ww.wp.xz.cn/plugins/insert-php/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Put your function in the functions.php file of your Child Theme instead.

    Thread Starter nimbus3000

    (@nimbus3000)

    Thanks a lot for the reply Andrew, but can you explain the answer a little. I am very new and not conversant with what a child theme is.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Sorry I misread your thread title and thought this was regarding a theme, not a plugin.

    Try this:

    [insert_php]
    include( $_SERVER["DOCUMENT_ROOT"] . "/public/document/location/of/file.php" );
    [/insert_php]

    Replace
    /public/document/location/of/file.php
    with the public document location of the file you’re including.

    As an example, if the URL to the file was http://example.com/testing/file.php, then replace
    /public/document/location/of/file.php
    with
    /testing/file.php

    For this particular include, assuming the file you’re including is named file.php, this should work:

    [insert_php]
    include( $_SERVER["DOCUMENT_ROOT"] . "/wordpress/file.php" );
    [/insert_php]

    Will

    Because there has been no response, I’m assuming the original poster resolved the issue.

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

The topic ‘using the include function’ is closed to new replies.