WordPress.org

Ready to get started?Download WordPress

Forums

php include in sidebar.php (4 posts)

  1. rlparker81
    Member
    Posted 3 years ago #

    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

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try using:

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

  3. rlparker81
    Member
    Posted 3 years ago #

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

  4. spstieng
    Member
    Posted 3 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

Tags

No tags yet.