Support » Plugins » WordPress – Fatal error: Call to a member function when calling class

  • I have created a php class in my theme function.php

    class myWidgetSetting {
    
        function get_title(){
         //some blah blah code
        }
    
    }
    
    $setting = new myWidgetSetting();

    but when I call this class $setting->get_title() inside:

    class myWidget extends WP_Widget {
        $setting->get_title();
    }

    Then I get this error:

    Fatal error: Call to a member function get_title() on a non-object in D:\wamp\www\wp-content\themes\twentyten\widgets\myWidget.php on line 3

    Do i need to register class to wordpress ??

    NOTE: Both class are in same file

  • The topic ‘WordPress – Fatal error: Call to a member function when calling class’ is closed to new replies.