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 might be doing this all wrong. I have a custom field called "enable_adsense" and the value can be either "yes" or "no"

What I'm trying to do is display something if the value is "yes" and something else if it's "no".

Here's what I have so far:

    <?php
global $post;
$enable_adsense = get_post_meta($post->ID, 'enable_adsense', true);
var_dump($enable_adsense);
if ($enable_adsense == 'yes') { ?>

    Adsense code goes here

<?php } else { ?>
share|improve this question
    
If your meta value is what you say it is that should work. What is the question? –  s_ha_dum Oct 17 '13 at 23:36
    
That's the thing it's not working. –  Chozen Oct 17 '13 at 23:40
    
Then your post meta is not what you say it is. Do some debugging-- say, var_dump($disable_adsense); –  s_ha_dum Oct 17 '13 at 23:42
    
This is how it appears: Screeenshot, does this have to be in the loop? Because it's in the sidebar and only returning what comes after the "else" –  Chozen Oct 17 '13 at 23:49
    
For $post to work correctly, yes, it has to be in a Loop. I didn't ask for a screenshot of the backend. I asked for a var_dump. –  s_ha_dum Oct 17 '13 at 23:58
show 3 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.