Support » How-To and Troubleshooting » php include in sidebar.php

php include in sidebar.php

  • Hi,

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi


    Forum Moderator

    Try using:

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

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

    drop the domain.co.uk.

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

    So just use include_once(‘functions/filename.php’)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘php include in sidebar.php’ is closed to new replies.