Widgets are normally displayed as part of a sidebar using the dynamic_sidebar()
function. There is the_widget function for static widgets, but there is no
equivalent for specific widgets configured in the Appearance > Widgets area.
The Widget Instance plugin allows WordPress users of all abilities to display
these widgets outside of the sidebars they have been assigned to.
- A wysiwyg editor button for selecting available widgets,
- A shortcode [widget_instance id=”[widget_id]”],
- A theme action do_action(‘widget_instance’, [widget_id]) and finally
- Utility functions for developers get_widget_instance and widget_instance
- [widget_instance id=”[widget_id]”]
- do_action(‘widget_instance’, ‘[widget_id]’);
- How do I get the widget id?
Of course the editor button automagically retrieves all the available widgets
(and their ids) for you, but if you are using one of the PHP functions, you can
get the available widget ids by looping over the array returned by the function
use with other plugin "Category Posts Widget" and template Customizr very easy
This plugin has saved me a lot of work and has given me all the answers I was looking for a long time ago.
Thank you very much Ben.
- Included Immánuel Fodor’s fix for empty dropdown
- Tested in WordPress 4.2.2, new banner, icons and tinymce button created.
- Can now select a widget by it’s title as well as its id. The title is in parenthesis after the id.
- Tested on 3.5.1
- Fixed php warnign typo
- Tested on 3.4.1
- Added option for including sidebar formatting
- The widget’s title will now include the sidebar title markup (More useful than having a plain text title)
- Initial release