The proper way to include/require PHP files in WordPress

If you check https://codex.wordpress.org/Function_Reference/get_template_directory_uri

You will see get_template_directory_uri() returns a uri, not a server path.

You should use instead the get_template_directory() function:

include get_template_directory() . 'subdir/filename.php';

For a plugin you can use the plugin_dir_path() function:

include plugin_dir_path( __FILE__ ) . 'subdir/filename.php';

Leave a Comment