2

I've created a custom widget that I've named openingTimesWidget which extends the WP_Widgets class and follows the guidelines for creating widgets...

What I'd now like to do is not only add this to a sidebar but be able to call upon it individually...So far I've tried using the_widget('openingTimesWidget') function directly within some HTML but it returns nothing...

1
  • If openingTimesWidget is your widget's classname this should work.
    – s_ha_dum
    Dec 23, 2015 at 4:08

1 Answer 1

2

The WordPress codex mentions you should call the Widget Class name. Could it be that openingTimesWidget is a function instead of a Class? Following the WP Class naming convention your class would be written like this Opening_Times_Widget. https://codex.wordpress.org/Widgets_API

Another possible reason that the widget is not displaying could have to do with the way your theme loads. I encountered a situation with the Roots theme where a widget in the site header would not load. This was caused by the specific way that Roots loads the theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.