In WordPress I'm using a plug in that logs a meta key _featured and adds a value of yes or no. I want to add css if it is featured, however it is adding the div no matter what the result.
<?php if ( get_post_meta( get_the_ID(), '_featured', true ) ) : ?>
<?php $feat = get_post_meta( get_the_ID(), '_featured', true ); ?>
<?php if( strcasecmp($feat, yes) == 0)?>
<a href=""><div class="featured_reject">Featured Rejection</div></a>
<?php endif; ?>
<h1><?php echo get_post_meta( get_the_ID(), '_featured', true ) ?></h1>
<?php endif; ?>
Not all of this is intended for the end, some of it is just to test the results of the log.
<?php if ( get_post_meta( get_the_ID(), '_featured', true ) ) : ?>
This checks if there is a value. Works fine.
<?php $feat = get_post_meta( get_the_ID(), '_featured', true ); ?>
Logging it as a variable
<?php if( strcasecmp($feat, 'yes') == 0)?>
<a href=""><div class="featured_reject">Featured Rejection</div></a>
<?php endif; ?>
This is the code to add the div. It adds it regardless of whether the value is yes or no.
<h1><?php echo get_post_meta( get_the_ID(), '_featured', true ) ?></h1>
<?php endif; ?>
This last portion is simply to check what the value is for myself.
I'm not sure where I am going wrong.
strtolower($feat) == 'yes'for my comparisonvar_dump($feat)output? You should use var_dump instead of echo to see the contents of a variable - it gives you the type of variable and other useful information.