Title: Exception in function.php
Last modified: October 21, 2016

---

# Exception in function.php

 *  Resolved [akachan](https://wordpress.org/support/users/akachan/)
 * (@akachan)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/exception-in-function-php/)
 * Hi.
 * i have this code in my function.php:
 *     ```
       add_filter( 'sidebars_widgets', function( $sidebars_widgets ) {
   
           $sidebar_index = 'sidebar-1';
   
           if( isset( $sidebars_widgets[$sidebar_index] ) )
           {
                 shuffle( $sidebars_widgets[$sidebar_index] );
       	  $sidebars_widgets[$sidebar_index] = array_slice( $sidebars_widgets[$sidebar_index], 0, 8 );
   
           }
           return $sidebars_widgets;
       }, PHP_INT_MAX );
       ```
   
 * Working perfect. I see 8 randomly widgets in one widget area. Problem is a see
   8 randomly widgets in my administration too. It is possible to make an exception
   in this code for admin area. I will see all widget there.
 * Thanks.

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/exception-in-function-php/#post-8339591)
 * try working with `is_admin()`, i.e. try to change the one line to:
 * `if( !is_admin() && isset( $sidebars_widgets[$sidebar_index] ) )`
 * [https://codex.wordpress.org/Function_Reference/is_admin](https://codex.wordpress.org/Function_Reference/is_admin)
 * (not tested)
 *  Thread Starter [akachan](https://wordpress.org/support/users/akachan/)
 * (@akachan)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/exception-in-function-php/#post-8340699)
 * I use is_front_page() and seems to be working.
 *     ```
       add_filter( 'sidebars_widgets', function( $sidebars_widgets ) {
   
           $sidebar_index = 'sidebar-1';
   
           if( is_front_page() && isset( $sidebars_widgets[$sidebar_index] ) )
           {
                 shuffle( $sidebars_widgets[$sidebar_index] );
       	  $sidebars_widgets[$sidebar_index] = array_slice( $sidebars_widgets[$sidebar_index], 0, 7 );
   
           }
           return $sidebars_widgets;
       }, PHP_INT_MAX );
       ```
   
 * Thank you to kick me in right way.

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

The topic ‘Exception in function.php’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [akachan](https://wordpress.org/support/users/akachan/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/exception-in-function-php/#post-8340699)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
