How to name different footer files which can be selected in wp-admin’s page editors

Seen this done before in other templates, just wondering if anyone here knows how to do this.

I have one template I have created, and two hard coded footer files. footer.php and footer-1.php.

Read More

I want to be able to select between using either footer.php or footer-1.php in wp-admin via the pages editor.

So far all I have found so far is adding something like this to the top of the file:

Template Name: footer_1

However, this requires that a secondary header and other files are also included, it won’t allow just a change of footer alone.

Can anyone tell me how I can name different footer files so that wordpress detects them in wp-admin and allows me to switch between them.

I do not require adding widgets to these, there is simply two styles of footer and they have no correlation to page or category to hard code, they have to be selected in the admin area manually.

Related posts

1 comment

  1. To dynamically change your footer with a admin editor option, do the following:

    1. Open the page you want to customize in editor
    2. Locate Custom Fields meta box in editor (If it is not visible tick the box Custom Fields in the Screen options dropdown at top right)
    3. Select Add Custom Field in Custom Fields meta box
    4. Enter footer_template in Name field and an arbitrary id in the Value field
    5. Select Update to save your settings

    6. Open your theme folder and locate page.php file

    7. Open page.php file and locate the very last line <?php get_footer(); ?>
    8. Delete the line in step 7 and add the following:

      <?php
      $scriptonomy_footer_meta = get_post_meta(get_the_ID(), 'footer_template', true);
      get_footer($scriptonomy_footer_meta); ?>

    9. Save and close page.php file

    10. Make a duplicate of footer.php and name it footer- plus any arbitrary id you chose in step 4, ie: footer-1.php or footer-two.php

    Now you can assign any custom footer to any page. You can do the same for the header as well using this technique.

Comments are closed.