Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save enqtran/2b91e67cf0c47b4535a33392b9038c23 to your computer and use it in GitHub Desktop.
Save enqtran/2b91e67cf0c47b4535a33392b9038c23 to your computer and use it in GitHub Desktop.
//add back to top admin
if ( ! function_exists( 'enqtran_back_to_top' ) ) {
function enqtran_back_to_top() {
echo '<a id="backtotop" href="#" style="position: fixed;
color: rgb(255, 255, 255);
right: 0px;
bottom: 5px;
text-decoration: none;
font-weight: bold;
padding: 7px 5px;
display: none;
background: rgb(0, 115, 170);">TOP</a>';
?>
<script>
jQuery(window).scroll(function() {
if(jQuery(window).scrollTop() > 500) {
jQuery('#backtotop').show();
} else {
jQuery('#backtotop').hide();
}
});
jQuery('#backtotop').click(function(event) {
event.preventDefault();
jQuery("body,html").animate({ scrollTop:0} );
});
</script>
<?php }
add_action('admin_footer', 'enqtran_back_to_top');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment