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

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

Something like:

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

Thanks a lot.

2 Answers 2

if ( get_bloginfo( 'description' ) ) {
    //do something

bloginfo echoes the description, get_bloginfo returns php variable

  • Thanks, but it doesn't work to me.
    – raymond
    Dec 1, 2011 at 16:46
  • This works: <?php if(get_bloginfo('description') <> '') { ?> // do something <?php } ?>
    – raymond
    Dec 1, 2011 at 16:51

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..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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