Insert a widget or multiple widgets or a entire widget area (sidebar) into a page using a shortcode.
Set up your widget first in a normal sidebar. Check it works.
THEN Drag your chosen widgets to the sidebar called "widgets for shortcode".
Add the do_widget shortcode to the page where you would like the widget to appear (or the do_widget_area)
To use in the block editor, add a shortcode block, then type in (including the square brackets [do_widget widgetname] or copy the do_widget tip from the widget in the 'Widgets for Shortcodes' sidebar.
Please see detailed info on shortcodes and parameters under the installation tab (depending what the plugin directory developers have most recently done, this may be under the FAQ, or at the very least under the readme.)
Using a widget more than once?
Reference a specific widget instance from the do_widget shortcode, or the chosen sidebar from the do_widget_area shortcode. Eg: [do_widget id=widget-n]
For example: You could use the query posts widget in the page to create a archive within a page, or the rss widget to list feed content from other sites. For more details see
anmari.com
The plugins default action is that it will magically find the settings for your themes sidebar and use the sidebar html to control the widgets output. In most cases this means the widget will be styled as per the rest of your theme. If that does not look good, parameters exist to try override this behaviour.
EG: in twenty-fourteen theme widget text ends up being white on white! widget_classes=none fixes that. Eg: [do_widget widget_classes=none yourwidget]
Changed your theme and worried about losing the sidebar settings ?
No problem, the plugin will save and restore the widgets_for_shortcode settings. On display it will then pick up the new themes sidebar settings.
Note:
PLEASE get your widgets working in a sidebar BEFORE activating this plugin, and please read
https://wordpress.org/plugins/amr-shortcode-any-widget/installation/ and
https://wordpress.org/plugins/amr-shortcode-any-widget/faq/ and/or see the settings page. To see a list of your widgets in their sidebars, add ?do_widget_debug to the page with the do_widget shortcode.
- Test your chosen widget in a normal sidebar or widget area first.
- Then activate this plugin
- Go to Appearance > widgets and find the " widgets for shortcode" sidebar or widget area
- Drag your chosen widget from your normal sidebar to the shortcodes sidebar. Save.
-
Now go to a page and enter a do_widget shortcode The shortcode any widget settings page has some helpful (hopefully) examples and links.
-
[do_widget widgetname] eg: [do_widget calendar]
- [do_widget "widget name"]. eg: [do_widget "tag cloud"]
- [do_widget id=widgetid] . eg: [do_widget id=tag-cloud-3]
- [do_widget_area] (will use the "widgets in shortcodes" widget area / sidebar
- [do_widget_area sidebarid] or [do_widget_area widget_area=sidebarid] for another sidebar or widget area - eg: to maximise likelihood of getting your theme's widget css to apply.
[do_widget ...] Parameters:
- nameofwidget or name="nameofwidget" This is NOT the title of the widget. THis is the name that you see in the widgets menu page even when unassigned to a sidebar. For existing users , you can also use just the name of the widget without name=. It must be the first parameter then. You can only do this with the name, not the id.
- id=wordpress assigned id of widget. Examples: id=meta-3, id=tag-cloud-9 etc
- title=false to hide the widgets title OR to override your themes first sidebar html settings for widget titles, use title=htmltag where htmltag is one of h1,h2,h3,h4,h5,header,strong,em.
- wrap=htmltag where htmltag is one of div,p,main,aside,section. This will override your themes first sidebar widget wrapping html.
- widget_classes=none This will remove the class "widget" from the wrapping html and the class "widget_title" from the title html. This may be enough to remove any unwanted css caused by your theme.
- class=yourclassname By default the plugin will add a class of amr-widget to the wrapping html. You can use this to add any special css. Add css either by editing your themes stylesheet if it is a custom theme, or using something like the wordpress custom css plugin.
- sidebar="sidebarname" will default to widgets_for_shortcode sidebar. Only use if you want to re-use a widget already being used in another sidebar. THis is theme dependent and WILL break if you change themes. Safer to use the widget_id.
[do_widget_area ...] Parameters:
- widget_area=yourwidgetarea defaults to 'widgets_for_shortcodes' if nothing entered
- widget_area_class=none / option to remove theme styling by removing the widget_area class from the sidebar html /
- widget_classes=none /* option to remove the widget class from the widget wrappinghtml
- class=yourclassname default is amr_widget_area. This will affect the widget area NOT the individual widgets. At the moment can only remove the widget classes, not replace them when using do_widget_area.
Advanced users WARNING: using do_widget_area with a widget area other than the shortcode one means that if you changes themes and the new theme has different sidebars, then this shortcode with a named widget area will not work.
See the settings page for links to help your create the shortcodes in a page.
The plugin has been tested with most standard widgets (rss feeds, tag cloud, pages, meta, search, and of course my own plugins widgets - upcoming events list, calendar and user lists.
If you use a widget more than once for different reasons, you may need to use the widget id to isolate which widget instance and it's settings to use. ie: [do_widget id=categories-6] . If you just use the name, it will display all widgets in the shortcode sidebar with that name (all instances).
If you liked this plugin, you might also like my other plugins:
- icalevents.com - a ics compliant events plugin fully integrated with wordpress, so it will work with many other plugins (seo, maps, social)
- wpusersplugin.com - a suite of plugins to help with membership sites. Major plugin is amr users