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.

Can someone tell, how to check whether it's empty?

<?php bloginfo('description'); ?>

Something like:

<?php if (!empty bloginfo('description');) ?>

Thanks a lot.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted
if ( get_bloginfo( 'description' ) ) {
    //do something
}

bloginfo echoes the description, get_bloginfo returns php variable

share|improve this answer
    
Thanks, but it doesn't work to me. –  raymond Dec 1 '11 at 16:46
    
This works: <?php if(get_bloginfo('description') <> '') { ?> // do something <?php } ?> –  raymond Dec 1 '11 at 16:51
add comment

Ptriek's example checks if the value is true and unfortunately an empty value still evaluates to true, hence why it doesn't work as expected. Try the following instead..

<?php if( !empty( get_bloginfo('description') ) : ?>

<!-- your html -->

<?php endif; ?>

NOTE: An empty check will also ring true for empty strings, so covers exactly the same case as the code you posted in the comment on ptriek's answer..

share|improve this answer
add comment

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.