Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter akachan

    (@akachan)

    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.

    Thread Starter akachan

    (@akachan)

    I have another problem with it. All is working in frontpage, but in adminitration too. I see 8 widgets randomly there, like it was a frontpage. It is possible to make in this code an exception for admininistration side of my web?

    Thanks.

    Thread Starter akachan

    (@akachan)

    O-ho! It is alive! 🙂

    Solved. Thank you.

    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 );
Viewing 3 replies - 1 through 3 (of 3 total)