Title: get_dynamic_sidebar function needed or perhaps a hook?
Last modified: August 19, 2016

---

# get_dynamic_sidebar function needed or perhaps a hook?

 *  [.sarah.](https://wordpress.org/support/users/sarah-1/)
 * (@sarah-1)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/get_dynamic_sidebar-function-needed-or-perhaps-a-hook/)
 * Widgets are great to give the user control over what goes in a sidebar.
 * However in the case of plugins sometimes we need to get the code and control 
   how/when its echo’d out.
 * Therefore it would be great to have **get_dynamic_sidebar** that returns the 
   string.
 * The alternative would be a hook that is called after the user leaves the loop(
   somehow). The idea is that the plugin can run without requiring the user to update
   their templates. The benefits are
    1. User can use widgets to control the options without creating more submenus in
       the Settings section
    2. User doesn’t need to be familiar with editing templates
    3. User can change templates without worrying that they’ll lose functionality, 
       create work etc

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Rocio Valdivia](https://wordpress.org/support/users/_dorsvenabili/)
 * (@_dorsvenabili)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/get_dynamic_sidebar-function-needed-or-perhaps-a-hook/#post-1670410)
 * Meanwhile it is developed in the core, I have found this one in the trunk, you
   can use it 😉
 * function get_dynamic_sidebar($index = 1)
    { $sidebar_contents = “”; ob_start();
   dynamic_sidebar($index); $sidebar_contents = ob_get_clean(); return $sidebar_contents;}
 *  [ryanve](https://wordpress.org/support/users/ryanve/)
 * (@ryanve)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get_dynamic_sidebar-function-needed-or-perhaps-a-hook/#post-1670508)
 * [@_dorsvenabili](https://wordpress.org/support/users/_dorsvenabili/) That worked
   for me =) Do you remember the link to where you found it? It definitely seems
   like it would be useful to have it as an official function.
 *  [ryanve](https://wordpress.org/support/users/ryanve/)
 * (@ryanve)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get_dynamic_sidebar-function-needed-or-perhaps-a-hook/#post-1670509)
 * Ah found it, for anyone else looking, see: [core.trac.wordpress.org/ticket/13169](http://core.trac.wordpress.org/ticket/13169)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘get_dynamic_sidebar function needed or perhaps a hook?’ is closed to 
new replies.

## Tags

 * [dynamic_sidebar()](https://wordpress.org/support/topic-tag/dynamic_sidebar/)

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 3 replies
 * 3 participants
 * Last reply from: [ryanve](https://wordpress.org/support/users/ryanve/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/get_dynamic_sidebar-function-needed-or-perhaps-a-hook/#post-1670509)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
