{"id":188,"date":"2017-10-18T11:49:56","date_gmt":"2017-10-18T11:49:56","guid":{"rendered":"https:\/\/learningcurve.xyz\/?p=188"},"modified":"2017-10-18T13:10:50","modified_gmt":"2017-10-18T13:10:50","slug":"genesis-framework-hidden-footer","status":"publish","type":"post","link":"https:\/\/learningcurve.xyz\/?p=188","title":{"rendered":"Genesis Framework Hidden Footer"},"content":{"rendered":"<p>If you scroll down to the bottom of this site, you&#8217;ll see that you can scroll past the content and my site footer will be &#8216;revealed&#8217;. Visually, the effect is that the site content is sliding up from infront of a hidden footer, it&#8217;s pretty neat and something I&#8217;d seen implemented on a variety of other sites, so I dug into their code and implemented it myself.<\/p>\n<p>This tutorial is pretty specific to sites using the <a href=\"https:\/\/my.studiopress.com\/themes\/genesis\/\" target=\"_blank\" rel=\"noopener\">Genesis Framework<\/a>, as it makes use of the framework&#8217;s extensive hooks. It should be achievable with some of the other Frameworks and their hooks, but you&#8217;ll need to adapt the code to fit.<\/p>\n<p>It&#8217;s pretty easy to achieve with just a few simple steps:<\/p>\n<ol>\n<li>Unregister the default Genesis footer.<\/li>\n<li>Register a new widget area.<\/li>\n<li>Add markup for the widget area, position it after the site container using Genesis hooks.<\/li>\n<li>Fix the widget in position at the bottom of the page with CSS.<\/li>\n<li>Add some jQuery so we can always see the widget area.<\/li>\n<\/ol>\n<p>So without any further ado, let&#8217;s get started&#8230;<\/p>\n<h2>1. Unregister the default Genesis footer<\/h2>\n<p>Genesis Framework makes this unbelievably easy, providing great functions for both our needs. To do this, just add the following code to your theme&#8217;s <span class=\"grey-code\">functions.php<\/span>:<\/p>\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522.js?file=remove-original-footer.php\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522\">Gist<\/a>.<\/noscript><\/div>\n<p>Remember, don&#8217;t include the opening <span class=\"grey-code\">&lt;?php <\/span> tag, that&#8217;s just included so the Gist shows correct syntax highlighting!<\/p>\n<h2>2. Register a new widget area<\/h2>\n<p>Again, Genesis is our friend. We can use a Genesis function to register our new widget and it will take care of attributes etc. Add this code just after the previous code in your theme&#8217;s <span class=\"grey-code\">functions.php<\/span>:<\/p>\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522.js?file=register-new-widget.php\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522\">Gist<\/a>.<\/noscript><\/div>\n<h2>3. Add markup for widget area<\/h2>\n<p>Next, use the <span class=\"grey-code\">genesis_after<\/span> action hook to add the widget&#8217;s markup. This will position it at the very end of the page, after the site-container.<\/p>\n<p>Add the following to your <span class=\"grey-code\">functions.php<\/span>:<\/p>\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522.js?file=position-genesis-after-add-markup.php\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522\">Gist<\/a>.<\/noscript><\/div>\n<h2>4. Fix the widget position with CSS<\/h2>\n<p>We need to fix the widget at the page bottom as static. Also, the effect becomes less visually successful on smaller mobile devices, so we also want to set this to only happen on screen sizes above 1024px. Given the content is already static, the best way to do this is with mobile first (min-width) css.<\/p>\n<p>Adjust the following to fit your theme&#8217;s aesthetic, and add it to its <span class=\"grey-code\">style.css<\/span>:<\/p>\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522.js?file=style.css\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522\">Gist<\/a>.<\/noscript><\/div>\n<p>The site-container <em>must<\/em> have a <span class=\"grey-code\">background-color<\/span>, and a higher <span class=\"grey-code\">z-index<\/span> than the widget area (ie be infront of it). The <span class=\"grey-code\">add-hidden-footer-margin<\/span> class will be added dynamically with jQuery later, this ensures that the widget isn&#8217;t hidden if the browser doesn&#8217;t load the <span class=\"grey-code\">.js<\/span> for wharever reason.<\/p>\n<h2>5. Add jQuery to control visibility<\/h2>\n<p>We need to add a margin to the <span class=\"grey-code\">site-container<\/span> so that the user can &#8216;scroll past&#8217; the end of the container, and in doing so reveal the hidden widget area. This margin must be set at the exact height of the widget area itself, otherwise the user wouldn&#8217;t be able to scroll far enough, or would scroll too far.<\/p>\n<p>This is where we use jQuery to add the class dynamically, but only if the screensize matches the mobile-first css rules.<\/p>\n<p>Creat a <span class=\"grey-code\">hidden-footer.js<\/span> file and place it in <span class=\"grey-code\">\/wp-content\/themes\/your-theme\/js\/<\/span>. The add the following code to it:<\/p>\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522.js?file=hidden-footer.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522\">Gist<\/a>.<\/noscript><\/div>\n<p>Once that is done, we need to enqueue our script properly, add the following to your <span class=\"grey-code\">functions.php<\/span>:<\/p>\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522.js?file=enqueue-hidden-footer-script.php\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/JeffCleverley\/957d1f64ad5cc3dc74f2633b21e9c522\">Gist<\/a>.<\/noscript><\/div>\n<p>That should be it, now you should have a footer just as cool as mine!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you scroll down to the bottom of this site, you&#8217;ll see that you can scroll past the content and my site footer will be &#8216;revealed&#8217;. Visually, the effect is that the site content is sliding up from infront of a hidden footer, it&#8217;s pretty neat and something I&#8217;d seen implemented on a variety of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4],"tags":[],"_links":{"self":[{"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=\/wp\/v2\/posts\/188"}],"collection":[{"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":1,"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/189"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=\/wp\/v2\/media\/174"}],"wp:attachment":[{"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learningcurve.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}