Skip Navigation

[Resolved] add widget to views

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to add WordPress widget with view's templates

Solution:
To add WordPress widget to view template you need to wrap your widget code with custom shortcode and then use the custom shortcode to display the widget with your view template.

The complete solution you will find on the following reply:
https://toolset.com/forums/topic/add-widget-to-views/#post-369022

Relevant Documentation:
http://codex.wordpress.org/Function_Reference/the_widget
http://codex.wordpress.org/Widgetizing_Themes

This support ticket is created 8 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by christerA 8 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#368923

Hi, I am trying to:
add the normal WordPress widgets to the templates in Views.
How do i do that?

#369022

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

To add WordPress widget to view template you need to wrap your widget code with custom shortcode and then use the custom shortcode to display the widget with your view template.

For example, To display categories widget - add following shortcode to current theme's functions.php file:

add_shortcode('add_widget_to_view_template', 'widget_to_view_template');
 function widget_to_view_template($atts, $content = '') {
	return the_widget( 'WP_Widget_Categories', 'dropdown=1&count=1' );
}

Call shortcode with your view template:

[add_widget_to_view_template]

More Info:
http://codex.wordpress.org/Function_Reference/the_widget
http://codex.wordpress.org/Widgetizing_Themes

#369074

Thanks, exactly what i was looking for!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.