Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active December 20, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/6129258 to your computer and use it in GitHub Desktop.
Save Shelob9/6129258 to your computer and use it in GitHub Desktop.
Function to create fixed position headers in WordPress. Assumes the header is wrapped in #header-wrap and site content to scroll underneath it is wrapped in #primary.
function slug_header-Stick($options) {
echo "<style> #header-wrap(position:fixed;}";
if (is_user_logged_in() ) {
echo "#header-wrap{ margin-top:19px; z-index:100; } </style>";
}
echo "</style>"
echo "
<script>
jQuery(document).ready(function($) {
$('#primary').css('padding-top', $('#header-wrap').height() + 'px');
}); //end no conflict wrapper
</script>
";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment