New widget area below the menu showing the footer content
-
Hi everyone!
It is my first time creating a new widget area via code. I wanted to create a space to include a banner and opt-in right below the main menu. I’ve managed to do that but it doesn’t show the widgets I’m including on the Widget menu. It is currently showing the same content appearing on the footer. If I change the widget on that new area, let’s say from an image to a text line, the actual height of the strip changes but still shows the footer.
What I’ve done is create a child theme, create a style.css file and rtl.css file (because there was one on the parent theme), create a fucntions.php file with the following code in it:
<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/rtl.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', get_stylesheet_directory_uri() . '/rtl.css', array('parent-style') ); } // Custom widget area. register_sidebar( array( 'name' => __( 'Custom Header Widget', 'cmsmasters'), 'id' => 'custom-header-widget', 'description' => __( 'An optional custom widget area for your site', 'cmsmasters' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>' ) );
Then I’ve imported the header.php file from the parent theme and have added the following code right after </header>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Custom Header Widget') ) : ?> <?php endif; ?>
I am a bit confused because inside the parent theme folder there is a directory called framework and inside there are files such us theme-functions.php and theme-functions-widgets.php
Inside this theme-functions.php file there is an area called /* Register Default Theme Sidebars */ where I’ve pasted the following code again (after importing the file on the child theme):
// Custom widget area. register_sidebar( array( 'name' => __( 'Custom Header Widget', 'cmsmasters'), 'id' => 'custom-header-widget', 'description' => __( 'An optional custom widget area for your site', 'cmsmasters' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>' ) );
I know I might be mixing things but it is my first time doing this and I don’t know how to fix this issue. How can I make the new widget area show the actual widgets I’m inserting on it?
Thanks a lot!
- The topic ‘New widget area below the menu showing the footer content’ is closed to new replies.