Have you taken the WordPress 2013 Survey yet? Search WordPress.org
Showcase
Themes
Plugins
Mobile
Support
Get Involved
About
Blog
Hosting
Codex
Download WordPress
Codex tools: Log in
Widgets API
Home Page WordPress Lessons
Languages: English • Español • 日本語 • 中文(简体) • (Add your language)
Getting Started Working with WordPress
This article is marked as in need of editing. You can help Codex by editing it.
Design and Layout
Widgets API This page contains the technical documentation for the WordPress Widgets API and is written for developers. If you're not a developer you may want to review the Widgets page. In technical terms: a WordPress Widget is a PHP object that echoes string data to STDOUT when its widget() method is called. It's located in wp-includes/widgets.php.
Function Reference
Contents
Advanced Topics
[hide]
Troubleshooting
1 Widgets API 2 Function Reference 3 Developing Widgets
3.2 Example
Codex Resources
3.3 Example With Namespaces
Community portal
4 Displaying Widgets and Widget Areas
6 Independent Widgets
Are you a developer? Try out the HTML to PDF API
About WordPress
3.1 Default Usage
5 Widget Areas
open in browser PRO version
Developer Docs
Current events Recent changes
6.1 Resources
Random page
6.2 Related
Help
pdfcrowd.com
Widget Functions
internal Functions
is_active_widget()
wp_register_widget_control()
the_widget()
wp_unregister_widget_control()
register_widget()
wp_convert_widget_settings()
unregister_widget()
wp_get_widget_defaults() wp_widget_description()
Developing Widgets To create a widget, you only need to extend the standard WP_Widget class and some of its functions. That base class also contains information about the functions that must be extended to get a working widget. The WP_Widget class is located in wp-includes/widgets.php.
Default Usage class My_Widget extends WP_Widget { public function __construct() { // widget actual processes } public function widget( $args, $instance ) { // outputs the content of the widget } public function form( $instance ) { // outputs the options form on admin }
open in browser PRO version
Are you a developer? Try out the HTML to PDF API
pdfcrowd.com
public function update( $new_instance, $old_instance ) { // processes widget options to be saved } }
The widget can then be registered using the widgets_init hook:
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.