wayahead
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [Twenty Twenty] Trying to add a sidebar above the headerOh my goodness, thank you so much!
Im not sure what I was missing but the code you just supplied made it all work.
Thank you very much for your help!Forum: Themes and Templates
In reply to: [Twenty Twenty] Trying to add a sidebar above the headerI have tried deactivating all the plugins except wpstaging and the child theme plugin.
Does it matter where in the functions.php or header.php file I place the code?
In functions I have just placed it at the end and in the header I placed it here –
`<?php
wp_body_open();
?>
<?php get_sidebar ( ‘sidebar-utility’ ); ?><header id=”site-header” class=”header-footer-group” role=”banner”>
I assume it is in the right place in the header.php as it does put a sidebar there just not the right one…
thanks again for your help
Forum: Themes and Templates
In reply to: [Twenty Twenty] Trying to add a sidebar above the headerHi,
Thanks for answering.
To the best of my knowledge i have followed the instructions on that page.
I am using a child theme.
Code on functions.php is-
function twentytwenty_widgets_init() {
register_sidebar( array(
‘name’ => __( ‘utility’, ‘twentytwenty’ ),
‘id’ => ‘utility’,
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
}
add_action( ‘widgets_init’, ‘my_register_sidebars’ );
function my_register_sidebars() {
/* Register the ‘utility’ sidebar. */
register_sidebar(
array(
‘id’ => ‘utility’,
‘name’ => __( ‘utility’ ),
‘description’ => __( ‘above header’ ),
‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’,
)
);}
Code on header.php –
<?php get_sidebar ( ‘utility’ ); ?>Code on sidebar-utility.php –
<div id=”utility” class=”sidebar”>
<?php dynamic_sidebar( ‘utility’ ); ?>
</div>Thanks so much,
Leanne