Viewing 13 replies - 1 through 13 (of 13 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    It depends how you get content into the footer in your theme. How do you do that?

    Please also post what Theme you are using – some (like Genesis and other premium Themes) make it difficult to modify the footer – on others it’s fairly simple if you’re comfortable copying & pasting some code into your footer.php file (a simple PHP statement that basically says ‘if it’s this page (or an array of pages or child pages of a parent page) use this footer, else use the default footer”…. many of us can help you by providing that code, but we need to know how your Theme calls your footer now.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    if content is done via widgets in a footer “sidebar” it’s fairly easy.

    Thread Starter Tsvetan Tsakov

    (@filesubmit)

    I am using Mediso theme.

    the footer contains 4 widgets

    this is my childs footer.php https://infinit.io/_/9qiVVeS

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    OK, so you can do something like this inside footer.php

    $type1 = array(1,2,3,4);  // where these are page ids that get the type 1 footer
    if ( is_page( $type1 ) || is_post ( $type1 ) ) {
        // do type 1 stuff
        } else {
        // do default stuff
        }
    Thread Starter Tsvetan Tsakov

    (@filesubmit)

    alright!

    in my page.php i replaced

    <?php get_footer(); ?>

    with

    <?php $type1 = array(15329,42); // where these are page ids that get the type 1 footer
    if ( is_page( $type1 ) || is_post ( $type1 ) ) {
    get_footer( ‘type1’ );
    } else {
    get_footer();
    } ?>

    and on the pages within the array it worked, but on all other pages, there was no footer

    p.s. i see you’ve updated the code. let me try now

    Thread Starter Tsvetan Tsakov

    (@filesubmit)

    this doesn’t seem to work (or maybe i am setting it up the wrong way), but the first one, with separate footer-type1.php file worked for the pages in array but the other pages displayed with no footer

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    use the code above in your footer.php; I revised my answer, apparently after the system mailed the earlier one to you.

    @filesubmit – either method should work fine.

    Your method (which is what I would do) is to call a different footer.php file for some pages (footer-type1.php).

    @sterndata’s method is to use one footer.php and just do different stuff based on the page calling it.

    Both are acceptable methods and your code above looks fine to me – I don’t see something that might be causing trouble, however sometimes it’s the unseen that does it – be sure there are no stray characters such as end-of-line stuff at the end of any line – you can check this by removing all the spaces except the necessary ones so your code would look like this:

    <?php $type1 = array(15329,42); if(is_page($type1) || is_post($type1)){get_footer('type1');}else{get_footer();} ?>

    Then if you really prefer the way it looks above, just very carefully put the spaces back in and test again.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    If TrishsaM’s suggestion doesn’t work, please put your footer.php into a gist on https://gist.github.com and paste a link to it here.

    Thread Starter Tsvetan Tsakov

    (@filesubmit)

    I tried and worked for the pages in the array, but for all other pages, there was no footer at all

    Here is my child’s theme footer.php: https://gist.github.com/FileSubmit/1b6f2075b03cc762fc0c35ddeb9709ec

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    you’re missing the default/fall-through condition

    if (it's one of these) {
       do this;
    } else {
       do that;
    }

    Actually the problem is that you have your code in the actual footer.php file, instead of in the page.php where your earlier post say that you put it….

    So you can do this (leave the code in your footer.php), and it can still work provided your footer-type1.php is complete (and calls wp_footer() at the bottom) BUT you’ll need to modify it so that the “else” statement just does what is below it, instead of recalling footer.php.

    To do that just remove
    get_footer();}
    so that it ends with
    } else { ?>

    And then at the VERY END after wp_footer(); put the closing brace } before the ?> and you should be good.

    This way, your page.php calls footer.php, and at the top of footer.php you have the test for your Page ID, which then says if it’s one of these pages use footer-type1.php, else do whatever is below (which is your normal footer stuff).

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to set different footer to selected pages’ is closed to new replies.