ok, so I have created a plugin in Wordpress. I want to be able to use some values I have created in a function within my template but I just don't seem to be able to get it to work.

I have created my plugin within a class the structure is:

class foo_class {

    public  $foo;

    public function __construct() {   

         $this->foo = 'hello';


    public function wordpress_test() {
        echo $this->foo;

$foo_class = new foo_class ();

Soooooo my thinking is within a theme file I should just be able to go...


but this seems to just stop loading the page when I hit the var_dump call. Am I hooking into this wrong?

  • 1
    Do you have debugging enabled? – Milo Nov 26 '14 at 16:59
  • yes, I get 'call_user_func_array() expects parameter 1 to be a valid callback, function 'wordpress_test' not found or invalid function name in...' – David Nov 26 '14 at 17:03
  • 2
    Also instantiate the object in your template instead. – Sisir Nov 26 '14 at 17:03
  • 1
    what happens if you add global $foo_class; before the var_dump? – Milo Nov 26 '14 at 17:10
  • 1
    Create a new instance in the theme file from the class of the plugin. $foo_class = new foo_class(); var_dump($foo_class->wordpress_test()); Maybe also check if the class is exists. Do you have debug mode active? – bueltge Nov 26 '14 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.