SlideShare a Scribd company logo
Creating Customizable
Widgets for
Unpredictable Needs
Amanda Giles
http://bit.ly/boswp1115
WordPress Boston – Nov 30, 2015 - #BostonWP
Who am I?
• Independent IT Consultant
• WordPress Developer (Themes and Plugins)
• Run the Seacoast NH WordPress Meetup
• Lover
• Fighter
• Sneezer
• Teacher / Trainer
• My favorite quote is from Calvin & Hobbes:
“Virtue isn’t better than vice, it’s just different.
http://bit.ly/boswp1115
And I have cats!
http://bit.ly/boswp1115
Information Gathering…
• Who here has used a widget?
• Who here has created a widget?
• Who has lost hours trying widget after widget
to find the “right” one?
http://bit.ly/boswp1115
Who is this talk geared towards?
Developers
http://bit.ly/boswp1115
But what if I’m not a
developer?
http://bit.ly/boswp1115
http://bit.ly/boswp1115
Why you should stay
(even if you’re not a developer)
• Might convince a plugin developer to modify a
widget to address your needs
• Might find a widget that’s close to your needs
and hire someone to modify it
• Might decide to roll up your sleeves and try your
hand at coding
http://bit.ly/boswp1115
What is a widget?
• A way to take [inputted] criteria from a WordPress user
and convert that to into output for a website visitor.
• Drag and Drop widgets into widget areas under
Appearance > Widgets
• Collect input [criteria] from user via a form
• When website is viewed, content is displayed to a
website visitor
http://bit.ly/boswp1115
Widget Examples
http://bit.ly/boswp1115
Why create your own widgets?
http://bit.ly/boswp1115
But seriously…
Creating widgets is a way to control
the content of what's being presented
while giving the user choices about
that content, its presentation, and its
location.
http://bit.ly/boswp1115
How do we do this?
For Users:
Anticipate what choices or variations
the user might want
For Developers:
Offer ways to adjust the
output where feasible
http://bit.ly/boswp1115
What does that mean?
For Users:
Anticipate what choices or variations
the user might want
• Offer choices to filter the content shown
• Offer choices about how that content is shown
• Offer style choices
• Provide basic clean styling or no styling
http://bit.ly/boswp1115
What does that mean?
For Developers:
Offer ways to adjust the
output where feasible
• Be sure to tag output elements with id/class so
styles can be easily overridden
• Use hooks to allow filtering of output (for
developers)
http://bit.ly/boswp1115
Anatomy of a widget
1. Declaration/Construct
Tell WordPress some information about your widget and how to identify it
2. User Interface / Form
Define the form that will gather user's choices about the widget instance
3. Update/Save Logic
Save the user's choices about the widget instance
4. Widget/Output Logic
Display the widget instance to the website visitor
5. Register the Widget
Tell WordPress to register your widget and include it on the
Appearance > Widgets page
http://bit.ly/boswp1115
Widget Code Structure
1. Declaration/Construct
2. User Interface / Form
3. Update/Save Logic
4. Widget/Output Logic
5. Register Widget using Widget Name
0. Widget Name & “extends WP_Widget”
http://bit.ly/boswp1115
“Show Posts” widget
We’re going to look at a widget that displays posts.
Our first pass, we’ll focus on the basic user choices:
• Specify Widget Title (or not)
• Choose one or more specific post IDs
• Choose post type (post, page, custom post types)
• Choose # of posts to show
• Choose what to sort by
• Choose the sort order (ascending, descending)
• Choose whether to show the post thumbnail/featured image
• Choose whether to display the full post content or excerpt
http://bit.ly/boswp1115
On to the coding!
http://bit.ly/boswp1115
Second Pass
On our second pass through the widget we will
add the following touches to flush it out further:
• Add CSS for the widget output on website
• Add CSS for the Admin User Interface/Form
• Place hooks to allow filtering on several
elements
http://bit.ly/boswp1115
What is a hook?
A hook is an "event" which allows for additional
code to be run when it occurs.
One or more functions can be associated with a
hook and they will all run when the hook is
triggered.
http://bit.ly/boswp1115
Why use hooks?
Hooks are placed within WordPress core, plugins,
and themes to allow customization by developers
without direct edits of the code.
Hooks are the proper way to alter the default
behavior of code which is not yours to edit.
http://bit.ly/boswp1115
Types of hooks
Action hooks allow you to run code at a certain
point within the code.
Examples in WP core include initialization, before
main query is run, header or footer of a page/post.
Filter hooks allow you to alter data, content,
parameters. A filter hook is passed information to
filter and returns it altered (or not).
Examples in WP code include displaying content,
page/post title, pre-saving content (admin).
http://bit.ly/boswp1115
http://bit.ly/boswp1115
Questions?
http://bit.ly/boswp1115
Thank You!
Find these slides and all related files at:
http://bit.ly/boswp1115
www.AmandaGiles.com
@AmandaGilesNH on Twitter
amanda@amandagiles.com
Please feel free to send me feedback or questions

More Related Content

PPTX
The Way to Theme Enlightenment
PPTX
Shortcodes vs Widgets: Which one and how?
PPTX
WordPress Theme Development: Part 2
PPTX
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
PPTX
Custom WordPress theme development
PDF
WordPress Theme Development for Designers
PPTX
Responsive Theme Workshop - WordCamp Columbus 2015
PDF
Intro to WordPress theme development
The Way to Theme Enlightenment
Shortcodes vs Widgets: Which one and how?
WordPress Theme Development: Part 2
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Custom WordPress theme development
WordPress Theme Development for Designers
Responsive Theme Workshop - WordCamp Columbus 2015
Intro to WordPress theme development

What's hot (20)

PPTX
Rebrand WordPress Admin
PPT
WordPress Child Themes
KEY
WordPress Developers Israel Meetup #1
PDF
WordPress Custom Fields: Control your content presentation by breaking out of...
PDF
WordPress Theme Structure
PDF
Seven deadly theming sins
PDF
Becoming a better WordPress Developer
KEY
Custom Post Types in Depth at WordCamp Montreal
PDF
Theming Wordpress with Adobe
PDF
Introduction to WordPress Theme Development
PPTX
Introduction to Custom WordPress Themeing
PDF
Theming 101
PPTX
Theme development essentials columbus oh word camp 2012
PDF
How to Prepare a WordPress Theme for Public Release
KEY
What is (not) WordPress
ODP
The Future Of WordPress Presentation
PDF
WordPress Theme Development
PDF
WordPress Custom Post Types
PPT
WordCamp Boston 2012 - Creating Content With Shortcodes
PPT
WordPress plugins
Rebrand WordPress Admin
WordPress Child Themes
WordPress Developers Israel Meetup #1
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Theme Structure
Seven deadly theming sins
Becoming a better WordPress Developer
Custom Post Types in Depth at WordCamp Montreal
Theming Wordpress with Adobe
Introduction to WordPress Theme Development
Introduction to Custom WordPress Themeing
Theming 101
Theme development essentials columbus oh word camp 2012
How to Prepare a WordPress Theme for Public Release
What is (not) WordPress
The Future Of WordPress Presentation
WordPress Theme Development
WordPress Custom Post Types
WordCamp Boston 2012 - Creating Content With Shortcodes
WordPress plugins
Ad

Similar to Creating Customizable Widgets for Unpredictable Needs (20)

PPTX
Technical SEO for WordPress Developers, Designers and Webmasters
PDF
Should you use WordPress for your non-profit websites?
PDF
WordPress Workshop with Tadpole, SATW 2013 Conference
PPTX
HTML Purifier, WYSIWYG, and TinyMCE
PDF
How to deliver a WordPress website to your client ...the RIGHT way
PPT
WordPress Complete Tutorial
PPTX
Creating Customizable Widgets for Unpredictable Needs
PPTX
A word press site even your mother can use
PPTX
A word press site even your mother can use
PPTX
A word press site even your mother can use
PPT
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
PDF
WordPress Plugins to add style to your website
PPTX
Wordpress Shortcode
PDF
PPTX
Developing Blocks without React - Attributes.pptx
PPTX
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts
PDF
Maintaining Retainers as a WordPress Developer
PPTX
WordPress Basics
PPT
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...
PPTX
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Technical SEO for WordPress Developers, Designers and Webmasters
Should you use WordPress for your non-profit websites?
WordPress Workshop with Tadpole, SATW 2013 Conference
HTML Purifier, WYSIWYG, and TinyMCE
How to deliver a WordPress website to your client ...the RIGHT way
WordPress Complete Tutorial
Creating Customizable Widgets for Unpredictable Needs
A word press site even your mother can use
A word press site even your mother can use
A word press site even your mother can use
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
WordPress Plugins to add style to your website
Wordpress Shortcode
Developing Blocks without React - Attributes.pptx
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts
Maintaining Retainers as a WordPress Developer
WordPress Basics
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Ad

Recently uploaded (20)

PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
top salesforce developer skills in 2025.pdf
PDF
medical staffing services at VALiNTRY
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PPT
Introduction Database Management System for Course Database
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Online Work Permit System for Fast Permit Processing
PDF
System and Network Administraation Chapter 3
PPTX
history of c programming in notes for students .pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
Operating system designcfffgfgggggggvggggggggg
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms II-SECS-1021-03
top salesforce developer skills in 2025.pdf
medical staffing services at VALiNTRY
VVF-Customer-Presentation2025-Ver1.9.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Design an Analysis of Algorithms I-SECS-1021-03
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Softaken Excel to vCard Converter Software.pdf
Introduction Database Management System for Course Database
Upgrade and Innovation Strategies for SAP ERP Customers
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Online Work Permit System for Fast Permit Processing
System and Network Administraation Chapter 3
history of c programming in notes for students .pptx
How Creative Agencies Leverage Project Management Software.pdf

Creating Customizable Widgets for Unpredictable Needs

  • 1. Creating Customizable Widgets for Unpredictable Needs Amanda Giles http://bit.ly/boswp1115 WordPress Boston – Nov 30, 2015 - #BostonWP
  • 2. Who am I? • Independent IT Consultant • WordPress Developer (Themes and Plugins) • Run the Seacoast NH WordPress Meetup • Lover • Fighter • Sneezer • Teacher / Trainer • My favorite quote is from Calvin & Hobbes: “Virtue isn’t better than vice, it’s just different. http://bit.ly/boswp1115
  • 3. And I have cats! http://bit.ly/boswp1115
  • 4. Information Gathering… • Who here has used a widget? • Who here has created a widget? • Who has lost hours trying widget after widget to find the “right” one? http://bit.ly/boswp1115
  • 5. Who is this talk geared towards? Developers http://bit.ly/boswp1115
  • 6. But what if I’m not a developer? http://bit.ly/boswp1115
  • 8. Why you should stay (even if you’re not a developer) • Might convince a plugin developer to modify a widget to address your needs • Might find a widget that’s close to your needs and hire someone to modify it • Might decide to roll up your sleeves and try your hand at coding http://bit.ly/boswp1115
  • 9. What is a widget? • A way to take [inputted] criteria from a WordPress user and convert that to into output for a website visitor. • Drag and Drop widgets into widget areas under Appearance > Widgets • Collect input [criteria] from user via a form • When website is viewed, content is displayed to a website visitor http://bit.ly/boswp1115
  • 11. Why create your own widgets? http://bit.ly/boswp1115
  • 12. But seriously… Creating widgets is a way to control the content of what's being presented while giving the user choices about that content, its presentation, and its location. http://bit.ly/boswp1115
  • 13. How do we do this? For Users: Anticipate what choices or variations the user might want For Developers: Offer ways to adjust the output where feasible http://bit.ly/boswp1115
  • 14. What does that mean? For Users: Anticipate what choices or variations the user might want • Offer choices to filter the content shown • Offer choices about how that content is shown • Offer style choices • Provide basic clean styling or no styling http://bit.ly/boswp1115
  • 15. What does that mean? For Developers: Offer ways to adjust the output where feasible • Be sure to tag output elements with id/class so styles can be easily overridden • Use hooks to allow filtering of output (for developers) http://bit.ly/boswp1115
  • 16. Anatomy of a widget 1. Declaration/Construct Tell WordPress some information about your widget and how to identify it 2. User Interface / Form Define the form that will gather user's choices about the widget instance 3. Update/Save Logic Save the user's choices about the widget instance 4. Widget/Output Logic Display the widget instance to the website visitor 5. Register the Widget Tell WordPress to register your widget and include it on the Appearance > Widgets page http://bit.ly/boswp1115
  • 17. Widget Code Structure 1. Declaration/Construct 2. User Interface / Form 3. Update/Save Logic 4. Widget/Output Logic 5. Register Widget using Widget Name 0. Widget Name & “extends WP_Widget” http://bit.ly/boswp1115
  • 18. “Show Posts” widget We’re going to look at a widget that displays posts. Our first pass, we’ll focus on the basic user choices: • Specify Widget Title (or not) • Choose one or more specific post IDs • Choose post type (post, page, custom post types) • Choose # of posts to show • Choose what to sort by • Choose the sort order (ascending, descending) • Choose whether to show the post thumbnail/featured image • Choose whether to display the full post content or excerpt http://bit.ly/boswp1115
  • 19. On to the coding! http://bit.ly/boswp1115
  • 20. Second Pass On our second pass through the widget we will add the following touches to flush it out further: • Add CSS for the widget output on website • Add CSS for the Admin User Interface/Form • Place hooks to allow filtering on several elements http://bit.ly/boswp1115
  • 21. What is a hook? A hook is an "event" which allows for additional code to be run when it occurs. One or more functions can be associated with a hook and they will all run when the hook is triggered. http://bit.ly/boswp1115
  • 22. Why use hooks? Hooks are placed within WordPress core, plugins, and themes to allow customization by developers without direct edits of the code. Hooks are the proper way to alter the default behavior of code which is not yours to edit. http://bit.ly/boswp1115
  • 23. Types of hooks Action hooks allow you to run code at a certain point within the code. Examples in WP core include initialization, before main query is run, header or footer of a page/post. Filter hooks allow you to alter data, content, parameters. A filter hook is passed information to filter and returns it altered (or not). Examples in WP code include displaying content, page/post title, pre-saving content (admin). http://bit.ly/boswp1115
  • 26. Thank You! Find these slides and all related files at: http://bit.ly/boswp1115 www.AmandaGiles.com @AmandaGilesNH on Twitter amanda@amandagiles.com Please feel free to send me feedback or questions