Title: Need php code to hide widget on certain pages
Last modified: August 30, 2016

---

# Need php code to hide widget on certain pages

 *  [peachysaving](https://wordpress.org/support/users/peachysaving/)
 * (@peachysaving)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/need-php-code-to-hide-widget-on-certain-pages/)
 * I’m not fluent in code. I’ve tried to figure this out on my own and just can’t.
   Can someone please piece this together for me??
 * I need to hide the Floating Social Media Links widget only on the theme’s microsite
   template.
 * I found a year-old post where the plugin author said there isn’t a way to do 
   this aside from editing php, but didn’t give the php code to use.
 * From the read-me file:
 * >  If you are, siply copy this code: <?php floating_social_media_links() ?> and
   > paste it into each template file that is used for the pages that you want [
   > the widget to appear]
 * But I don’t want to edit every single page type. I just want to stick one piece
   of code into the microsite page template php file.
 * Could someone please help? Thank you in advance!

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/need-php-code-to-hide-widget-on-certain-pages/#post-6878725)
 * The problem is when you add a widget to a sidebar, that widget appears where 
   ever the sidebar appears. If there’s nothing else in the sidebar you could remove
   the sidebar from the one template. Otherwise you’d need to declare a custom widget
   that is coded to not output content on a particular template, or create a new
   sidebar for use only on the one template that does not contain the widget. Neither
   of these last two options is trivial.
 * Another possibility is remove the widget, then go into each template _except_
   microsite page template and add the `<?php floating_social_media_links() ?>` 
   near the `dynamic_sidebar()` call. It may not be possible for it to be placed
   exactly where it is now with this approach.
 *  [Gorakh Shrestha](https://wordpress.org/support/users/gorakhsth/)
 * (@gorakhsth)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/need-php-code-to-hide-widget-on-certain-pages/#post-6878875)
 * If you have to hide in a page template simply use the following code.
 *     ```
       if ( ! is_page_template( 'template-microsite.php' ) ) {
       	floating_social_media_links();
       }
       ```
   
 * I hope this will help you.
 *  [Gorakh Shrestha](https://wordpress.org/support/users/gorakhsth/)
 * (@gorakhsth)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/need-php-code-to-hide-widget-on-certain-pages/#post-6878876)
 * If you have to hide in a page template simply use the following code.
 *     ```
       if ( ! is_page_template( 'template-microsite.php' ) ) {
       	floating_social_media_links();
       }
       ```
   
 * I hope this will help you and don’t forgot to change php file name as you have.

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

The topic ‘Need php code to hide widget on certain pages’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 3 participants
 * Last reply from: [Gorakh Shrestha](https://wordpress.org/support/users/gorakhsth/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/need-php-code-to-hide-widget-on-certain-pages/#post-6878876)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
