WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

is there any error in following code? when i use following code in content.php file of my theme, then nothing is displayed on blog, it seems there is some error. and when i comment folowing code everything gets back to normal.

<?php if (empty(get_custom_field_value("signature",""))) : ?>
    <?php the_category( '<span>/</span>' ); ?>      
<?php endif; ?>

here is get_custom_field_value function:

function get_custom_field_value($szKey, $prefix = '', $bPrint = false) {
    global $post;
    $szValue = get_post_meta($post->ID, $szKey, true);
    if ( $bPrint == false ) return (empty($szValue) ? "" : $prefix . $szValue); else echo (empty($szValue) ? $szValue : $prefix . $szValue);
share|improve this question
up vote 1 down vote accepted

empty will only take variables passed by reference. so empty(some_function()) will never work. See the php docs for more information.

<?php if (get_custom_field_value("signature","")) : ?>
    <?php the_category( '<span>/</span>' ); ?>      
<?php endif; ?>

You're better off just checking for the boolean, like above. The get_custom_field_value function already takes care of making sure you get something back.

On a side note: you should prefix your function names. get_custom_field_value is very generic. yourtheme_get_custom_field_value (replacing "yourtheme" with the theme name) has less of a chance of conflicting with other function names.

share|improve this answer
thanks, it works now :) – Zain Shaikh May 22 '12 at 18:15

Your Answer


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.