Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to hide a widget area after a certain time using jQuery. https://sridharkatakam.com/how-to-hide-a-widget-area-after-a-certain-time-using-jquery/
// Register before-header widget area
genesis_register_sidebar( array(
'id' => 'before-header',
'name' => __( 'Before Header', 'magazine' ),
'description' => __( 'This is the before header section', 'magazine' ),
) );
// Display before-header widget area before the header
add_action( 'genesis_before_header', 'sk_before_header' );
function sk_before_header() {
genesis_widget_area( 'before-header', array(
'before' => '<div class="before-header widget-area"><div class="wrap">',
'after' => '</div></div>',
) );
}
/*
Site Header
---------------------------------------------------------------------------------------------------- */
.primary-nav .site-header {
padding-top: 64px;
}
.site-header .wrap {
border-bottom: 2px solid #222;
padding: 30px 0;
}
/*
Site Header
---------------------------------------------------------------------------------------------------- */
/*.primary-nav .site-header,*/
.primary-nav .before-header.hidden + .site-header,
.primary-nav .before-header {
padding-top: 64px;
}
.before-header .wrap {
padding: 30px 0;
border-bottom: 1px solid #222;
}
.site-header .wrap {
border-bottom: 2px solid #222;
padding: 30px 0;
}
// Slide down before-header widget area and slide it up out of view after 3s
var tId;
$(".before-header").hide().slideDown("slow");
clearTimeout(tId);
tId=setTimeout(function(){
$(".before-header").slideUp("slow").addClass("hidden");
}, 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment