php include in sidebar.php (4 posts)

  1. rlparker81
    Posted 5 years ago #


    I have my wordpress blog installed on domain.co.uk/blog. I need to access some functions in domain.co.uk/functions/filename.php in my sidebar.php file.

    However if I <?php include('domain.co.uk/functions/filename.php')?> all it does is write the code in the included file to the page as text.

    Is it possible to include an external php file in sidebar.php? if so how/where do I do it?

    Thanks and sorry if this is a daft question as this is my first wordpress site. I found this post http://www.tomcatuk.net/how-to-use-a-php-include-with-wordpress/ but it didn't work either

    Thank you

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Try using:

    <?php include($_SERVER['DOCUMENT_ROOT'] . 'domain.co.uk/functions/filename.php')?>

  3. rlparker81
    Posted 5 years ago #

    thanks but that has the same affect. I don't understand why it is just writing the php to the screen.

  4. Steven
    Posted 5 years ago #

    drop the domain.co.uk.

    I'm guessing your root folder is /domain.co.uk.

    So just use include_once('functions/filename.php')

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.