Customizing Footer
-
Hello,
I’ve added a dashboard customizer tool so that users can customize the footer on my theme using:
<footer id=”colophon” class=”site-footer” role=”contentinfo”>
<div class=”site-info”>
<?php echo get_theme_mod( ‘copyright_textbox’, ‘No copyright information has been saved yet.’ ); ?>
</div><!– .site-info –></footer><!– #colophon –>
BUT I want my default footer to be the default wordpress footer which looks more like:
<footer id=”colophon” class=”site-footer” role=”contentinfo”>
<div class=”site-info”>
“><?php printf( __( ‘Proudly powered by %s’, ‘THEMESLUG’ ), ‘WordPress’ ); ?>
<span class=”sep”> | </span>
<?php printf( __( ‘Theme: %1$s by %2$s.’, ‘AC’ ), ‘THEMENAME’, ‘Underscores.me‘ ); ?>
</div><!– .site-info –>
</footer><!– #colophon –>How do I replace “No copyright information has been saved yet.’ with the default wordpress footer??
Thanks,
-
You might try something like this instead:
<?php if ( get_theme_mod( 'copyright_textbox' ) ) : echo get_theme_mod( 'copyright_textbox' ); else : ...default WordPress footer... endif; ?>Also, in the future, be sure to enclose all code within backticks (
`) so it displays correctly.Thanks for your reply. I’m just starting to learn php so the I’m having a hard time with the syntax.
When I do this I get an syntax error after the the word else :
if ( get_theme_mod( ‘copyright_textbox’ ) ) :
echo get_theme_mod( ‘copyright_textbox’ );
else :
<div class=”site-info”>
“><?php printf( __( ‘Proudly powered by %s’, ‘AC’ ), ‘WordPress’ ); ?>
<span class=”sep”> | </span>
<?php printf( __( ‘Theme: %1$s by %2$s.’, ‘AC’ ), ‘Artistic Collaboration’, ‘Underscores.me‘ ); ?>
</div><!– .site-info –>
endif;?>
You need to close off the PHP tags before you can put HTML tags or you’ll get syntax errors. Try this:
<?php if ( get_theme_mod( 'copyright_textbox' ) ) : ?> <div class="site-info"> <?php echo get_theme_mod( 'copyright_textbox' ); ?> </div><!-- .site-info --> <?php else : ?> <div class="site-info"> ... default WordPress footer... </div><!-- .site-info --> <?php endif; ?>HI,
If anyone is interested I got it to work like this:
<footer id=”colophon” class=”site-footer” role=”contentinfo”>
<div class=”site-info”>
<?php
if ( get_theme_mod( ‘copyright_textbox’ ) ) :
echo get_theme_mod( ‘copyright_textbox’ );
else :
echo ‘Proudly powered by ‘;
echo ‘WordPress ‘;
echo ‘Theme: THE THEME NAME by ‘;
echo ‘Underscores.me. ‘;endif;
?>
</footer><!– #colophon –>The only thing is, I’m working on my theme locally right now and when I try clicking on the link it doesn’t automatically take me to the site… is this because I’m working on the site locally??
Thank-you,
DewiIssued closed. Your code work. Thanks! Just learnt a lot!
The topic ‘Customizing Footer’ is closed to new replies.