Tell me more ×
WordPress Answers 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

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

ptriek's example checks if the value is true(an empty value still evaluates to true, hence why it doesn't work)..

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

<!-- your html -->

<?php endif; ?>

NOTE: An empty check with 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

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.