Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

CHAPTER 6 • Advanced Theme Usage 153


The label is descriptive, the type is checkbox (which will be unchecked by default), and it
belongs to the kihon_footer section that you created at the beginning.


That is all you need to save the data, but again, you need to actually do something with it
within the theme to make it matter. The solution is a simple one; you’ll just check to see if
kihon_footer_credits is checked, or 1 , which is the value for a true check box. If it is
checked, then you’ll output a simple display: none style that’ll hide it. The p tag contain-
ing all of this looks like this:


<p class="kihon-credits" <?php if ( get_theme_mod( 'kihon_footer_credits' ) == 1 )
{ echo 'style="display: none;"'; } ?>>



<?php bloginfo( 'title'); ?>
is powered by
WordPress and
Kihon by
TDH



So if get_theme_mod() with kihon_footer_credits passed to it is equal to 1 (or
checked), you’ll echo style="display: none;", thus not rendering the credit links
below. If it isn’t equal to 1 , the credit links will be rendered. Simple enough, right? Figure 6-6
shows the final Footer Details box in the Theme Customizer.


Figure 6-6: The final Footer Details box in the Theme Customizer.

Free download pdf