Readers like you help support MUO. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.

I read this article: https://www.makeuseof.com/tag/how-to-create-wordpress-widgets/ about how to create WordPress widgets. Everything went fine until this error page came out in my website:

Fatal error: Class 'RandomPostWidget' not found in C:\xampp\htdocs\sowhat\wp-includes\widgets.php on line 324

I sort of understand the problem, but I dont know how to fix it. In line 324, this is the code:

$this->widgets[$widget_class] = new $widget_class();

MAKEUSEOF VIDEO OF THE DAY
SCROLL TO CONTINUE WITH CONTENT

I think this happened because I changed the 'Random Post Widget' words to 'News Widget', including the class name. Maybe I did somthing wrong? Any help would be greatly appreciated!

muotechguy
2012-05-25 07:35:09
I should answer that since its my article... could you post your full code so we can see where you missed? The error implies the class name hasn't been changed everywhere its needed. Maybe just do a full text search and replace for 'RandomPostWidget' to 'NewsWidget'?