wordpress plugin require_once file – can’t user wordpress functions

I read a lot about the require_once in stackoverflow.

But no anwser solved my problem.

Read More

I’ve a plugin with two files.

dmd_main.php //main file

dmd_second.php //some WP functions

In my main file I’ve included this line:

require_once (plugin_dir_path(__FILE__) . 'includes/dmd_second.php');

But on my second file I still got the errormessage:

Call to undefined function get_option()

I read that this is the right way to work with the wordpress functions or not?

I’ve tried a lot and this code will work if I include it in my second file:

include_once($_SERVER['DOCUMENT_ROOT'].'wp-config.php' );

But this solution is realy bad.

Can somebody explain me how I can solve this problem?

Related posts

Leave a Reply