1

I want to create a page template that doesn't use footer. Removing get_footer() will not work in this case. Because my theme adds the stylesheets and scrtipts after the footer (before /body) and if I remove get_footer() all the scripts and styles are not loaded which will mess up css styling on the page.

I tried to create a separate file footer-none.php without footer area elements and used get_footer(none);. But this is not working.

Can you please help me with this?

Thanks.

1
  • 3
    Did you try get_footer(none); or get_footer('none');? The argument should be a string.
    – Milo
    Commented Jan 27, 2015 at 17:30

2 Answers 2

2

The correct way to load footer-none.php is:

get_footer("none");

Anyway, I think it can be better to use wp_footer() (required function on any frontend page) directly in the page template file so you don't need to load any empty footer template (assuming you load all required HTML tags in the page template, for example closing body and html).

If you are going to use the custom footer template in more than one page, then it would be better to maintain a separated custom footer template. It is up to your preference.

-1
  1. Create a child theme (if you don't already have one) of your current theme and activate it.
  2. Copy footer.php from the parent theme to the child theme and modify it to display only what you want. Make sure you leave the php code in there (do_action('%whatever%');) and only remove the actual content that you want removed.

If you only want this only on certain pages, use WP conditionals like is_page(%page_id%), is_archive(), is_author(), etc... to load no content only on the pages where you want no footer and load the normal content of the footer on the rest of the pages.

This way your changes to footer.php will not get overridden by any future updates of the parent theme.

Basically, not loading footer.php is generally not a good idea, as most plugin and theme developers consider it a place where it's safe to hook a script as it usually gets loaded on all pages. However, If you decide to create a template and not load footer.php in it, you should run all the actions that are run from the theme's footer.php from your template. Also you should check for any tags that are closed in the theme's footer and copy those too, or you'll break the page.

3
  • 1
    The question is about creating a page template with no footer, not a theme with no footer.
    – cybmeta
    Commented Jan 27, 2015 at 17:38
  • You're right. So I guess he needs a conditional in the modified footer.php, from the child theme: if(is_page(%page_id%)) { // load no footer } else { //load the normal footer}. I still think this should be done in a child theme, not in parent theme.
    – tao
    Commented Jan 27, 2015 at 17:40
  • @cybmeta I updated my answer. Thank you for pointing it out.
    – tao
    Commented Jan 27, 2015 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.