0

I would like to make a plug-in that adds a widget. I would like it to be based on the current pages widget but add the ability to select either include OR exclude by drop down or checkbox then list pages by ID.

Following this guide I was able to change the exclude to include by hacking the core file located in wp-includes/default_widgets.php.

Here is the original code:

http://pastebin.com/Rg2vTMmK

How do I make the changes and turn it into a plugin?

Many Thanks

1

Widgets are class based, so it is quite easy to extend them.

  1. Create your class by extending WP_Widget_Pages (just like it extends baseline Widget).

  2. Copy method(s) you want to modify into your class and make changes in there. You would probably want to extend and modify name and such so it is not confused/conflicted with native widget.

  3. Register your class using register_widget().

  • That is a great start, I googled "extends WP_Widget_Pages" and only found gist.github.com/967910 which is a start, but its not a plugin....Then I found this guide Not sure how to do it.... – Anthony Oct 19 '11 at 12:32
0

Found a solution here: http://wordpress.org/extend/plugins/widgets-reloaded/

  • I would recommend that one, but you worded your question as plugin development issue, not plugin recommendation. Please mention that existing plugin would be viable answer if so when asking. – Rarst Oct 20 '11 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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