We help IT Professionals succeed at work.
Get Started
Troubleshooting Question

How to implement a "sticky" footer in different types of wordpress pages

Last Modified: 2021-01-14

I am working on a wordpress website and want to implement a footer that is pushed to the lower edge of the browser screen if the content get´s smaller than the browser screen hight.

I want to use this approach:

Now I am looking for an effective way with JS,CSS and HTML to implement that for 2 different page types and one media query breakpoint. As I am a true beginner in all three languages here is a pseudo code setup I came up with:


var FooterHight = 157px 

@media only screen and (min-width: 768px)

if pagetype = hompage

         var HeaderHight = 288px

         Set CSS for homepage:
         .content {
           min-height: calc(100vh - (HeaderHight + FooterHight));         // 445px

         var HeaderHight = 63px
         Set CSS for all other pages: 
         content {
           min-height: calc(100vh - (HeaderHight + FooterHight));         // 220px

@media only screen and (max-width: 768px)

if pagetype = hompage

         var HeaderHight = 248px 

         Set CSS for homepage:
         .content {
           min-height: calc(100vh - (HeaderHight + FooterHight));         // 405px 
         var HeaderHight = 63px
         Set CSS for all other pages: 
         content {
           min-height: calc(100vh - (HeaderHight + FooterHight));         // 220px


First question: Could anybody please update my pseudo code to real code that works within wordpress?

Second question: Where do I put the code within wordpress so it is not spread on different locations?

Thanks for any help!

Watch Question
Founder & Creative Director
This problem has been solved!
Unlock 1 Answer and 16 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE