开发者

wordpress page template requre_once() failed

I want t开发者_开发百科o use a class file in a WordPress page template, but after adding the require_once() method, and trying to instance the class, I got

Fatal error: Class 'ClassName' not found,

the class file is displayed as html to the output page.

Any idea why this is happening? (I put the page template file and the class file under the theme directory)


Try: require_once(TEMPLATEPATH . '/ClassName.php');

Edit: Sorry, the file apparently has been found correctly. So then you need the class to be defined in that file looking like this:

class ClassName {
   Your code here
}
  1. Do you have included the class {} construct?
  2. Is the name of your class the same as you are trying to instantiate? $obj = new ClassName(); ?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜