Title: Use before_widget in sidebar.php?
Last modified: August 20, 2016

---

# Use before_widget in sidebar.php?

 *  [mikedev](https://wordpress.org/support/users/mikedev/)
 * (@mikedev)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/use-before_widget-in-sidebarphp/)
 * I want to style an item in a sidebar as if it were a widget.
 * I tried this code in sidebar.php, but it doesn’t display the widget wrapper:
 *     ```
       <?php echo $before_widget ?>
       my code
       <?php echo $after_widget ?>
       ```
   
 * It seems to only work in functions.php. Is there a way to get before_widget to
   work in a template like sidebar.php?

The topic ‘Use before_widget in sidebar.php?’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 0 replies
 * 1 participant
 * Last reply from: [mikedev](https://wordpress.org/support/users/mikedev/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/use-before_widget-in-sidebarphp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
