Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Are you using absolute or relative path? What is your file really named (this might matter)? –  Rarst Jul 26 '11 at 20:15

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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