How to make condition, based on custom fields value?

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…

Read More
<?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!

Related posts

Leave a Reply

1 comment

  1. 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.