Title: php help &#8211; widgets and sidebars
Last modified: August 19, 2016

---

# php help – widgets and sidebars

 *  [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/php-help-widgets-and-sidebars/)
 * So…
 * Why can’t I get the same widget to appear on 2 sidebars?
 * Let’s say there’s a widget in my functions.php file that looks like this:
 *     ```
       function skyscraper_widget() {
       	echo '
       		<div id="sky-ad" class="widget">'
       SOME ADD CODE GOES HERE
       		'</div>';
       }
       wp_register_sidebar_widget('skyscraper_widget', __('Sidebar Ads'),  'skyscraper_widget');
       ```
   
 * It seems to appear under “Available WIdgets” in the widget screen and I can drag
   it to a sidebar and then it works. Great. But now it’s not available for a second
   sidebar! Why is that?
 * I figured out by trial and error that I could create widgets by copying some 
   of those functions and then changing the names. So If I do this:
 *     ```
       function skyscraper_widget2() {
       	echo '
       		<div id="sky-ad" class="widget">'
       SOME ADD CODE GOES HERE
       		'</div>';
       }
       wp_register_sidebar_widget('skyscraper_widget2', __('Duplicate Sidebar Ads'),  'skyscraper_widget2');
       ```
   
 * Now I get a duplicate, it’s available, and I can drag it to my second sidebar.
 * I assume what I’m doing here is an ugly hack right? What’s the correct way to
   do this?

The topic ‘php help – widgets and sidebars’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [nickaster](https://wordpress.org/support/users/nickaster/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/php-help-widgets-and-sidebars/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
