content-home a strange thing
-
I have added to homepage 3 widget (I have copied and modified the code of the footer).
the widget are perfect, but in home page they are displayed two times.in function.php I add`
if ( ! function_exists( ‘wpforge_widgets_init’ ) ) {
function wpforge_widgets_init() {
register_sidebar( array(
‘name’ => __( ‘Main Sidebar’, ‘wp-forge’ ),
‘id’ => ‘main-sidebar’,
‘description’ => __( ‘Displays widgets in the blog area as well as pages.’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h6 class=”widget-title”>’,
‘after_title’ => ‘</h6>’,
) );
register_sidebar( array(
‘name’ => __( ‘First Footer Widget Area’, ‘wp-forge’ ),
‘id’ => ‘footer-sidebar-1’,
‘description’ => __( ‘An optional widget area for your site footer’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h6 class=”widget-title”>’,
‘after_title’ => ‘</h6>’,
) );
register_sidebar( array(
‘name’ => __( ‘Second Footer Widget Area’, ‘wp-forge’ ),
‘id’ => ‘footer-sidebar-2’,
‘description’ => __( ‘An second optional widget area for your site footer’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h6 class=”widget-title”>’,
‘after_title’ => ‘</h6>’,
) );
register_sidebar( array(
‘name’ => __( ‘Third Footer Widget Area’, ‘wp-forge’ ),
‘id’ => ‘footer-sidebar-3’,
‘description’ => __( ‘An third optional widget area for your site footer’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h6 class=”widget-title”>’,
‘after_title’ => ‘</h6>’,
) );
register_sidebar( array(
‘name’ => __( ‘Fourth Footer Widget Area’, ‘wp-forge’ ),
‘id’ => ‘footer-sidebar-4’,
‘description’ => __( ‘An fourth optional widget area for your site footer’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h6 class=”widget-title”>’,
‘after_title’ => ‘</h6>’,
) );
register_sidebar( array(
‘name’ => __( ‘First Home Widget Area’, ‘wp-forge’ ),
‘id’ => ‘home-sidebar-1’,
‘description’ => __( ‘An optional widget area for your home’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
register_sidebar( array(
‘name’ => __( ‘Second Home Widget Area’, ‘wp-forge’ ),
‘id’ => ‘home-sidebar-2’,
‘description’ => __( ‘An second optional widget area for your home’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
register_sidebar( array(
‘name’ => __( ‘Third home Widget Area’, ‘wp-forge’ ),
‘id’ => ‘home-sidebar-3’,
‘description’ => __( ‘An third optional widget area for your home’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
register_sidebar( array(
‘name’ => __( ‘Fourth home Widget Area’, ‘wp-forge’ ),
‘id’ => ‘home-sidebar-4’,
‘description’ => __( ‘An fourth optional widget area for your home’, ‘wp-forge’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h6 class=”widget-title”>’,
‘after_title’ => ‘</h6>’,
) );
}
add_action( ‘widgets_init’, ‘wpforge_widgets_init’ );
}
/**
* Footer Sidebars. This will count the number of footer sidebars to enable dynamic classes in the footer area.
*/
if ( ! function_exists( ‘wpforge_footer_sidebar_class’ ) ) {
function wpforge_footer_sidebar_class() {
$count = 0;if ( is_active_sidebar( ‘footer-sidebar-1’ ) )
$count++;if ( is_active_sidebar( ‘footer-sidebar-2’ ) )
$count++;if ( is_active_sidebar( ‘footer-sidebar-3’ ) )
$count++;if ( is_active_sidebar( ‘footer-sidebar-4’ ) )
$count++;$class = ”;
switch ( $count ) {
case ‘1’:
$class = ‘medium-12 large-12’;
break;
case ‘2’:
$class = ‘medium-12 large-6’;
break;
case ‘3’:
$class = ‘medium-12 large-4’;
break;
case ‘4’:
$class = ‘medium-12 large-3’;
break;
}if ( $class )
echo ” . $class . ”;
}
}
if ( ! function_exists( ‘wpforge_home_sidebar_class’ ) ) {
function wpforge_home_sidebar_class() {
$count = 0;if ( is_active_sidebar( ‘home-sidebar-1’ ) )
$count++;if ( is_active_sidebar( ‘home-sidebar-2’ ) )
$count++;if ( is_active_sidebar( ‘home-sidebar-3’ ) )
$count++;if ( is_active_sidebar( ‘home-sidebar-4’ ) )
$count++;$class = ”;
switch ( $count ) {
case ‘1’:
$class = ‘medium-12 large-12’;
break;
case ‘2’:
$class = ‘medium-12 large-6’;
break;
case ‘3’:
$class = ‘medium-12 large-4’;
break;
case ‘4’:
$class = ‘medium-12 large-3’;
break;
}if ( $class )
echo ” . $class . ”;
}
}`and in content-home.php this is my code
<div id="home-sidebar" class="sidebar_wrap row widget-area" > <?php if ( is_active_sidebar( 'home-sidebar-1' ) ) : ?> <div class="<?php wpforge_home_sidebar_class(); ?> columns"> <?php dynamic_sidebar( 'home-sidebar-1' ); ?> </div><!-- .first --> <?php endif; ?> <?php if ( is_active_sidebar( 'home-sidebar-2' ) ) : ?> <div class="<?php wpforge_home_sidebar_class(); ?> columns"> <?php dynamic_sidebar( 'home-sidebar-2' ); ?> </div><!-- .second --> <?php endif; ?> <?php if ( is_active_sidebar( 'home-sidebar-3' ) ) : ?> <div class="<?php wpforge_home_sidebar_class(); ?> columns"> <?php dynamic_sidebar( 'home-sidebar-3' ); ?> </div><!-- .third --> <?php endif; ?> <?php if ( is_active_sidebar( 'home-sidebar-4' ) ) : ?> <div class="<?php wpforge_home_sidebar_class(); ?> columns"> <?php dynamic_sidebar( 'home-sidebar-4' ); ?> </div><!-- .fourth --> <?php endif; ?> </div><!-- #home sidebar -->
I really cannot solve this problem. Can anyone help me?
Tnx in advancePaolo
- The topic ‘content-home a strange thing’ is closed to new replies.