Add text/code to footer.php via child theme
-
Hi Guys,
I’m new to WordPress, trying out a localhost install to experiment and learn (hopefully for a larger project in due course).
I want to know how create a child php file that will allow me to insert code into an area of the footer.php of my parent theme…..
I am using the Qwerty Theme from SevenBold.com. I want to add my Copyright element in the footer. The theme come with three footer widget areas, but I hate the alignment of the text when doing it this way.
I do however like the alignment of the ‘Qwerty Theme by Seven Bold’ so i went into the footer.php and found this code:
<?php /** * The template for displaying the footer. * * Contains the closing of the #content div and all content after * * @package qwerty */ ?> </div><!-- #content --> <?php get_sidebar(); ?> <footer id="colophon" class="site-footer" role="contentinfo"> <div class="site-info"> <?php printf( __( '<a href="https://sevenbold.com/wordpress/qwerty/">%1$s Theme</a> <i>by</i> %2$s', 'qwerty' ), 'Qwerty', '<a href="https://sevenbold.com/wordpress/" rel="designer">Seven Bold</a>' ); ?> </div><!-- .site-info --> </footer><!-- #colophon --> </div><!-- #page --> <?php wp_footer(); ?> </body> </html>
I got the exact effect I wanted by inserting the line:
<?php printf( __( ' <br \> Copyright M&E Events Ltd. 2016 Company Number XXXXXXX Vat Number XXXXXXX <br \> <br \>' )); ?>
Directly above the theme link
making:
<?php /** * The template for displaying the footer. * * Contains the closing of the #content div and all content after * * @package qwerty */ ?> </div><!-- #content --> <?php get_sidebar(); ?> <footer id="colophon" class="site-footer" role="contentinfo"> <div class="site-info"> <?php printf( __( ' <br \> Copyright M&E Events Ltd. 2016 Company Number XXXXXXX Vat Number XXXXXXX <br \> <br \>' )); ?> <?php printf( __( '<a href="https://sevenbold.com/wordpress/qwerty/">%1$s Theme</a> <i>by</i> %2$s', 'qwerty' ), 'Qwerty', '<a href="https://sevenbold.com/wordpress/" rel="designer">Seven Bold</a>' ); ?> </div><!-- .site-info --> </footer><!-- #colophon --> </div><!-- #page --> <?php wp_footer(); ?> </body> </html>
All is well, except, I’ve edited the main theme…. I want to do the same thing, inserting the same line, but via child themes.
I don’t know if it’s possible, but in keeping with best practices I don’t simply want to override the parent footer.php just in case a future theme update edited the footer.php file…
Is this possible via functions.php?
I hope that makes sense…
TL;DR I want to add a specific line of php/code into a specific div of a theme using child themes rather than editing the parent.
- The topic ‘Add text/code to footer.php via child theme’ is closed to new replies.