0

I am using a theme and the developer doesnt want to help me make a widget on the templates/footer.php

The curently code at this php file is

<div class="bw-footer <?php echo isset( $class ) ? $class : ''; ?>">
    <div class="row">

        <?php
            $footer_logo = Bw::get_option('footer_logo');

            if( $footer_logo ) {
                echo "<div class='footer-logo'><img src='" . esc_attr( $footer_logo ) . "' alt=''></div>";
            }

            if ( has_nav_menu( 'footer' ) ) {
                echo '<nav class="navigation-footer">';
                    wp_nav_menu( array( 'theme_location' => 'footer' ) );
                echo '</nav>';
            }

            echo '<div class="footer-copy">' . Bw::esc_kses( Bw::get_option( 'footer_text' ), '' ) . '</div>';

            echo Bw::go_social( 'bw-social-uc' );
        ?>

    </div>
    <div class="footer-after bw-end-label"><div class="after back-top"><i class="fa fa-angle-up"></i></div></div>
</div>

Could you please help me make a widget area for the footer so i can add one "Newsletter" form (something like mailpoet plugin)? Thanks a lot.

Update. This is the "wp-content/themes/themename/footer.php file

<?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the #content div and all content after
 *
 * @package Bad Weather
 */
?>
    </div> <!-- #container -->
</div> <!-- #wrapper -->

<?php wp_footer(); ?>

</body>
</html>
2
  • Your theme doesn't have anything in that file that you can use without hacking the theme code, which is bad practice. What is in the wp-content/themes/{theme-name}footer.php file?
    – s_ha_dum
    Commented Nov 25, 2015 at 20:53
  • @s_ha_dum i updated the question. Commented Nov 25, 2015 at 20:57

1 Answer 1

0

Your theme appears to be loading its "footer" via code hooked into the wp_footer action, since there is no other obvious code that would do it. Of course, this is based on the limited code you have posted.

This means that you should be able to remove and replace the footer code used by the theme.

remove_action('wp_footer','callback_for_footer');
add_action('wp_footer','callback_for_new_footer');

You will need a callback something like:

function callback_for_new_footer() { ?>
  <div class="bw-footer <?php echo isset( $class ) ? $class : ''; ?>">
    <div class="row"><?php
      // add components or remove them
      $footer_logo = Bw::get_option('footer_logo');

      if( $footer_logo ) {
        echo "<div class='footer-logo'><img src='" . esc_attr( $footer_logo ) . "' alt=''></div>";
      }

      if ( has_nav_menu( 'footer' ) ) {
        echo '<nav class="navigation-footer">';
          wp_nav_menu( array( 'theme_location' => 'footer' ) );
        echo '</nav>';
      }

      echo '<div class="footer-copy">' . Bw::esc_kses( Bw::get_option( 'footer_text' ), '' ) . '</div>';

      echo Bw::go_social( 'bw-social-uc' ); ?>
    </div>
    <div class="footer-after bw-end-label"><div class="after back-top"><i class="fa fa-angle-up"></i></div></div>
  </div><?
}

You could also add elements before or after the theme's footer by playing with the hook priority:

add_action('wp_footer','callback_for_new_footer',5); // before (probably)
add_action('wp_footer','callback_for_new_footer',15); // after (probably)

You should be making these changes in the context of a child theme, as any other changes will be overwritten, and it is possible that in that context you could simply create a file with your desired content at templates/footer.php in the child theme and have it load. That does depend on how the parent is written of course, most importantly on whether it uses get_template_part() to load the file.

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.