Title: Custom widget doesn&#8217;t activate.
Last modified: January 12, 2018

---

# Custom widget doesn’t activate.

 *  Resolved [palychwp](https://wordpress.org/support/users/palychwp/)
 * (@palychwp)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/)
 * Custom widget won’t activate. I folowed your [guide](https://siteorigin.com/docs/widgets-bundle/getting-started/creating-a-widget/)
   but widget doesn’t work. I activated it but after page reload it’s disabled again
   and I can’t use it.
 * I created plugin
 *     ```
       <?php
       /*
       Plugin Name: My Extended Widgets
       Description: Custom Widgets.
       Version: 0.1
       */
       function add_my_awesome_widgets_collection($folders){
           $folders[] = __DIR__ . '/widgets';
           return $folders;
       }
       add_filter('siteorigin_widgets_widget_folders', 'add_my_awesome_widgets_collection');
       ```
   
 * and widget:
 *     ```
       <?php
       /*
       Widget Name: First Test Widget!!
       Description: An example widget.
       Author: Me
       */
   
       class My_First_Test_Widget extends SiteOrigin_Widget {
   
           function __construct() {
               //Here you can do any preparation required before calling the parent constructor, such as including additional files or initializing variables.
   
               //Call the parent constructor with the required arguments.
               parent::__construct(
               // The unique id for your widget.
                   'my-first-test-widget',
   
                   // The name of the widget for display purposes.
                   __('First Test Widget', 'hello-world-widget-text-domain'),
   
                   // The $widget_options array, which is passed through to WP_Widget.
                   // It has a couple of extras like the optional help URL, which should link to your sites help or support page.
                   array(
                       'description' => __('A hello world widget.', 'hello-world-widget-text-domain'),
                       'help'        => 'http://example.com/hello-world-widget-docs',
                   ),
   
                   //The $control_options array, which is passed through to WP_Widget
                   array(
                   ),
   
                   //The $form_options array, which describes the form fields used to configure SiteOrigin widgets. We'll explain these in more detail later.
                   array(
                       'text' => array(
                           'type' => 'text',
                           'label' => __('Hello world! goes here.', 'siteorigin-widgets'),
                           'default' => 'Hello world!'
                       ),
                   ),
   
                   //The $base_folder path string.
                   plugin_dir_path(__FILE__)
               );
           }
   
           function get_template_name($instance) {
               return 'first-widget-template';
           }
   
           function get_template_dir($instance) {
               return 'templates';
           }
   
           function get_style_name($instance) {
               return '';
           }
   
       }
   
       siteorigin_widget_register('my-first-test-widget', __FILE__, 'My_First_Test_Widget');
       ```
   
 * This is my directory structure : [https://prnt.sc/hzf0fg](https://prnt.sc/hzf0fg)
    -  This topic was modified 8 years, 4 months ago by [palychwp](https://wordpress.org/support/users/palychwp/).

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Contributor [alexgso](https://wordpress.org/support/users/alexgso/)
 * (@alexgso)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9864816)
 * Hi palychwp,
 * Based on your screenshot and code, the issue is your widgets directory. Specifically,
   it’s not widgets directory, it’s literally a widget. You need to move the contents
   of the widgets directory into a directory specific to that widget so SiteOrigin
   Page Builder can reliability pick up on.
 * For reference, [here’s a screenshot](https://siteorigin.com/wp-content/gh-docs/docs/widgets-bundle/images/hello-world-widget-directory-structure.png)
   from the linked document with the correct structure.
 *  Thread Starter [palychwp](https://wordpress.org/support/users/palychwp/)
 * (@palychwp)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9872820)
 * Hi alexgso
 * I have changed directory structure: [http://prntscr.com/i1n6qt](http://prntscr.com/i1n6qt)
   
   My plugin file extend-widgets-bundle.php code:
 *     ```
       <?php
       /*
       Plugin Name: My Extended Widgets
       Description: Custom Widgets.
       Version: 0.1
       */
       function add_my_awesome_widgets_collection($folders){
           $folders[] = __DIR__ . '/extra-widgets';
           return $folders;
       }
       add_filter('siteorigin_widgets_widget_folders', 'add_my_awesome_widgets_collection');
       ```
   
 * Widget isn’t displaying in the list of widgets now.
 * I’m confused. Can I download sample of custom widget anywhere?
 *  Plugin Contributor [alexgso](https://wordpress.org/support/users/alexgso/)
 * (@alexgso)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9876334)
 * Hi palychwp,
 * You can find example widgets [here](https://github.com/siteorigin/so-dev-examples).
 * Would it be possible for you to send me a complete copy of your plugin so I can
   inspect your setup more closely?
 *  Thread Starter [palychwp](https://wordpress.org/support/users/palychwp/)
 * (@palychwp)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9888130)
 * Thanks alexgso!
 * This demos works perfectly.
    Thanks for help!
 *  Plugin Contributor [alexgso](https://wordpress.org/support/users/alexgso/)
 * (@alexgso)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9888168)
 * Hi palychwp,
 * Did you manage to get your widget working? If so, do you still need assistance
   with this issue?
 *  Thread Starter [palychwp](https://wordpress.org/support/users/palychwp/)
 * (@palychwp)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9888198)
 * I created my widget based on this demo. It’s working now.
 * Thanks a lot.
 *  Plugin Contributor [alexgso](https://wordpress.org/support/users/alexgso/)
 * (@alexgso)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9888229)
 * Hi palychwp,
 * Okay cool. I’m marking this thread as resolved.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Custom widget doesn’t activate.’ is closed to new replies.

 * ![](https://ps.w.org/so-widgets-bundle/assets/icon.svg?rev=2556862)
 * [SiteOrigin Widgets Bundle](https://wordpress.org/plugins/so-widgets-bundle/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/so-widgets-bundle/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/so-widgets-bundle/)
 * [Active Topics](https://wordpress.org/support/plugin/so-widgets-bundle/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/so-widgets-bundle/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/so-widgets-bundle/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [alexgso](https://wordpress.org/support/users/alexgso/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-doesnt-activate/#post-9888229)
 * Status: resolved