Checking if a Custom Field exists
-
I’m new to PHP. I’m successfully using
$mycustomfield = get_post_meta($post->ID, 'hair-color', true); if ($mycustomfield = ' ') { echo '' ;}
My question is: why doesn’t this work with
if ($mycustomfield = '')
rather thanif ($mycustomfield = ' ')
?I thought that ” meant ‘nothing’ and ‘ ‘ meant non-breaking space (which is how the echo works). Does ‘ ‘ actually mean ‘does not exist’ when it’s used with a variable?
Thanks,
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Checking if a Custom Field exists’ is closed to new replies.