WordPress.org

Support

Support » Plugins and Hacks » Hacks » How to include() a file from other dir

How to include() a file from other dir

  • Hi, folks.

    I need to include a file from another plugin into my new plugin, but I just can’t figure out how to indicate the paths correctly.

    My new file is in /plugins/new_plugin/new_plugin.php and I want to include a file that lies in /plugins/old_plugin/old_plugin.php

    I just need to
    include '/old_plugin/old_plugin.php';

    I’ve used the $_SERVER, WP_PLUGINS_DIR, ABS_PATH, and every single suggestion I’ve found in the webs.

    Some of them work just when viewing the plugin admin page, others work only when viewing the blog homepage, some do not work at all, but none work for the plugin page AND the homepage.

    At the home page I receive a PHP message stating the files cannot be found, or the page just does not render.

    What is the correct way to include a file that lies in another dir?

    Thanks a lot!

  • The topic ‘How to include() a file from other dir’ is closed to new replies.
Skip to toolbar