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.

So what i would like to do is order in some CSS depending on the value of a custom field.

The code below just says that if there is ANY value, do X, else do nothing...

<?php $pageNumbered=get_post_meta($post->ID, 'page-number', true); ?>
    <?php if ( $pageNumbered ) : ?>
        <div class="page-number left">
            <?php echo get_post_meta($post->ID, "page-number", true); ?>
        </div>              
        <?php else : ?>

    <?php endif; ?>

...what i want to do is say if the value is X do Y, if it is Z do XY etc etc...

Thanks guys!

share|improve this question
    
So why not add in a couple of simple if conditions? –  t31os Apr 12 '11 at 13:29
    
Yeah, but what i am saying is that i don't know how to bind a specific value to the if condition –  Infocentre Apr 12 '11 at 13:32
3  
This is a PHP question, not a WordPress question. I vote we move it over to stack overflow. –  John P Bloch Apr 12 '11 at 13:34
add comment

1 Answer

up vote 1 down vote accepted

Sorry but it's not clear what you want to do. From what I understand is you simply want to use an elseif statement:

<?php $pageNumbered=get_post_meta($post->ID, 'page-number', true); ?>

<?php if ( $pageNumbered ) : ?>
    <div class="page-number left">
        <?php echo get_post_meta($post->ID, "page-number", true); ?>
    </div>              
<?php elseif($pageNumbered == "Z") : ?>
    <div class="page-number left">
        <?php echo get_post_meta($post->ID, "page-number", true); ?>
    </div>
<?php endif; ?>

If you can edit you question to be clearer then I might be able to help more.

share|improve this answer
    
Sorry, i was unclear but i think you have just answered my question anyway! == "Z" means that the value must equal Z. Whereas true just needs to contain any value –  Infocentre Apr 12 '11 at 13:40
    
@Infocentre you know there is an extensive list of syntax's and functions in the php manual :) –  Xavier Apr 12 '11 at 14:01
    
@infocentre - tizag.com/phpT/elseif.php quick tutorial on elseif PHP statements. –  Brady Apr 12 '11 at 14:12
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.