Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using: get_theme_mod to show various pieces of info from the theme customizer, in the following format:

<a href=" <?php get_theme_mod( $name, $default ) ?> ">This is the link</a>

I would like to hide the whole line if that particular customizer field is empty.

What could I wrap around the anchor to accomplish this?

share|improve this question

1 Answer 1

$value = get_theme_mod( $name, $default );
if ($value !== $default) { 
?>
   <a href=" <?php echo $value; ?> ">This is the link</a>
<?php 
}
share|improve this answer
    
Awesome, thanks Otto! Funny you answered, as it's from your customizer tutorial I'm following. Where abouts would I place this code? In functions.php? –  user2014024 Feb 25 '13 at 23:37
    
Wherever the code you had above is, most likely your template. –  Wyck Feb 26 '13 at 3:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.