Title: Custom Widget Code
Last modified: August 22, 2016

---

# Custom Widget Code

 *  Resolved [sandyfischler](https://wordpress.org/support/users/sandyfischler/)
 * (@sandyfischler)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/custom-widget-code/)
 * I’ve got multiple tabs open with tutorials for creating a custom WP widget and
   I’m confused since they are all saying slighting different things.
 * I’ve created my plugin and it shows up in the plugin list (good so far).
 * Where I’m challenged is in adding the code to actually create the widget and 
   what order things go in since each tutorial is doing it differently and I’d like
   to start out with Best Practices.
 * This where I am so far and I’m already stuck because I have questions….
 *     ```
       <?php
       /*
       Plugin Name: Fuller Donation Widgets
       Description: Donation channel widgets
       Author: Sandy Fischler
       Version: 1
       */
       /* Start Adding Functions Below this Line */
   
       class fuller_of_openstrap_donation_page_one extends WP_Widget {
           function fuller_of_openstrap_donation_page_one() {
               parent::__construct(false, $name = __('Fuller Donation Widget One', 'fuller_of_openstrap_donation_page_one') );
           }
       ```
   
 * Questions:
 * 1) Do I state the class first or register the widget first? I see it done both
   ways. One tutorial starts out with register widget and another has it much lower
   in the code.
 * 2) In the WP codex they use **parent::__construct**, in one tutorial they use**
   parent::WP_Widget** which is correct?
 * Thanks!

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/custom-widget-code/?output_format=md) [1](https://wordpress.org/support/topic/custom-widget-code/?output_format=md)
2

 *  Thread Starter [sandyfischler](https://wordpress.org/support/users/sandyfischler/)
 * (@sandyfischler)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-code/page/2/#post-5632596)
 * That was it – I had some white space at the end of my functions.php file.
 * You are such a lifesaver….thank you, thank you, thank you.
 *  [Ryan Sechrest](https://wordpress.org/support/users/sovereign/)
 * (@sovereign)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-code/page/2/#post-5632597)
 * Sure, no problem. If all of your initial questions are resolved, too, go ahead
   and mark this topic as resolved.
 *  Thread Starter [sandyfischler](https://wordpress.org/support/users/sandyfischler/)
 * (@sandyfischler)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/custom-widget-code/page/2/#post-5632598)
 * For the record, here is how our spiffy new widgets came out with Ryan’s awesome
   help!
 * [http://fullercenterlosangeles.org/donate/](http://fullercenterlosangeles.org/donate/)
 *  [Wildcard](https://wordpress.org/support/users/thenewguy_14/)
 * (@thenewguy_14)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/custom-widget-code/page/2/#post-5632738)
 * Did you guys ever find out how to get the form inputs to stay displayed when 
   you drag and drop the widget into the sidebar? is there a way to trigger the 
   save button on the drop action?

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/custom-widget-code/?output_format=md) [1](https://wordpress.org/support/topic/custom-widget-code/?output_format=md)
2

The topic ‘Custom Widget Code’ is closed to new replies.

## Tags

 * [widgets](https://wordpress.org/support/topic-tag/widgets/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 19 replies
 * 4 participants
 * Last reply from: [Wildcard](https://wordpress.org/support/users/thenewguy_14/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/custom-widget-code/page/2/#post-5632738)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
