0

I'm trying to create a settings page. If I print things within index, I can see it. If I try to include it, I can't see anything, neither errors.

add_options_page('My Plugin', 'My Plugin', 'manage_options', 'my-plugin', array('MyPluginSettings', 'index'));

my settings:

class MyPluginSettings
{
    public function index()
    {
        /* I can echo or print here and it works fine ...
         * But i can't require a file here ... nothing happens
         */
        require('existing/path/to/a/file.php');
    }
}

?>

What's wrong? Thanks.

1
  • Are you using absolute or relative path? What is your file really named (this might matter)?
    – Rarst
    Commented Jul 26, 2011 at 20:15

1 Answer 1

1

Most likely the file cannot be found, I'm assuming the file you're trying to include is located in your theme folder, in that case you should use:

require_once( TEMPLATEPATH . '/file.php');

TEMPLATEPATH will return something like this: /home/user/httdocs/wp-content/themes/twentyeleven.

Worst case scenario you'll find a Fatal Error, but that'll help to find the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.