Yes, look at the widget()
method in your MyWidget
class. Does it echo? Most likely it does, because that’s how widgets are normally written. In fact, I’d be surprised to see a widget that didn’t echo output in its widget()
method.
And when you call the_widget()
, it fetches an instance of the widget you ask for, and calls $widget_obj->widget($args, $instance);
. So it echos, and doesn’t return anything.