Our simple widget is technically functional, but it doesn't do anything yet. After you have activated your widget and viewed your homepage, you will see some default text that we pointed out earlier: function WP_Widget::widget() must be over-ridden in a sub-class.
This is the output of the WP_Widget
class' widget()
function. If we think about our parent/child analogy, here we are getting a message from the parent telling the kid that he needs to take care of this function himself. How do we override the WP_Widget::widget()
function? We simply add a widget()
function to our ContentRotatorWidget
class. Add the following function to the ContentRotatorWidget.php
file, somewhere below the __construct()
function (remember we like to keep our functions alphabetized):
/** * Displays content to the front-end. * * @param array $args Display arguments * @param array $instance The settings for the particular instance of the widget * @return none No direct output. This should...