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.

I am trying to figure out why this page is showing content when the criteria isn´t being met.

I am using this code, so if there is a website in the custom meta box if will display the DIV with the a href in it:

<?php $infos = get_post_custom_values('_url'); ?>
<?php the_content(); ?></br class="clear">
<?php if ( $infos ) { ?>
  <div class="color-buttons color-button-blue website"><a href="http://<?php echo $infos[0]; ?>" target="_blank">Website →</a></div>
<?php } // endif ?>

If you look here: hhttp://globalicn.com/preview/regions/europe/#southern-europe the bottom Portugal link has no website, but the website link is there and shows http:///

If I delete the tag associated with this post, then the website link doesn´t display, which is correct. So when I add the tag Souther-Europe it somehow still adds the link.

Full code: http://pastebin.com/8taYL6Da

share|improve this question
add comment

1 Answer

Doesn't look like the return value of `get_post_custom_values()' is well defined in the codex. My guess is that as long as you have a costume field called '_url' set in any of your posts the result will be an empty array, and only if you don't have it in any post it will return null.

You probably better replace your check to

if (!empty($infos))
share|improve this answer
    
I always lean toward !empty(...) for this reason. –  s_ha_dum Dec 28 '12 at 14:56
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.