WordPress.org

Support

Support » Plugins and Hacks » Conditional statement with array value always false

Conditional statement with array value always false

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor madalin.ungureanu

    @madalinungureanu

    Hi!
    CFC always stores it’s data as serialized array( array ) even if you only have one entry or you set up a single entry meta box, so it should be if( <?php $info= get_post_meta($post->ID, ‘info’, true); if ( isset($info[0][‘test’]) ) { ?>

    Thanks for your reply. Sadly, that method will always return a true (might be the php version and isset problem with multidimensional arrays?)

    Anyway, this will do the trick even though it’s not pretty:

    <?php $info = get_post_meta($post->ID, 'info', true);  foreach($info as $info) { 
    
     if ($info['test']) { echo 'true'; } else { echo 'false'; }
    
      }  ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditional statement with array value always false’ is closed to new replies.