[wp-hackers] Widget Weirdness - Doesn't like the file name widgets.php

John Blackbourn johnbillion+wp at gmail.com
Mon Jun 27 14:45:52 UTC 2011

On 27 June 2011 14:13, Alex Andrews <awgandrews at gmail.com> wrote:
> Hey folks,
> Getting something odd going on with Widgets. In the context of a
> theme, I am attempting to add customised widgets. For ease of coding,
> widgets live in another file includes/widgets.php.
> If I do, in the functions.php file:
> require_once('includes/widgets.php');
> function buffer_widgets_init () {
>    register_widget('buffer_latest_features_widget');
> }
> add_action('widgets_init', 'buffer_widgets_init');
> Then it fails with a message: Fatal error: Class
> 'buffer_latest_features_widget' not found in
> /Users/alex/Sites/wp-includes/widgets.php on line 324.

Your include() line is trying to include the widgets.php file inside
wp-admin/includes. You should either use a full path in your
include(), or rename the file.

More information about the wp-hackers mailing list