I can only really seem to find documentation on wether one get_field exists or not.

Is it possible to put multiple get_field's into one variable and use that variable to check if any of the singular get_field variables exist?

So for example I have these variables below, and then put them all into one: $promotions


    $rider_plan_code        = get_field('rider_plan_code');
    $low_rate_finance_code  = get_field('low_rate_finance_code');
    $custom_promo_code      = get_field('custom_promo_code');

    $promotions = isset( $rider_plan_code, $low_rate_finance_code, $custom_promo_code );


Then I am using this... <?php if ($promotions) { ?> to check if any of those variables exist, but its not working.

Can anyone point out what I'm doing wrong?

Many Thanks

See below how I am using this...

<div class="btn-group">

    <a class="btn " href="#"><i class="icon-share"></i> Post to wall</a>

    <a class="btn <?php if ($promotions) { echo 'dropdown-toggle'; } ?> pricing-btn" href="#" title="Pricing" <?php if ($promotions) { echo 'data-toggle="dropdown"'; } ?>>
        <strong>&#163;<?php the_field('rrp-pound-sterling'); ?></strong><?php if ($promotions) { echo ' <span class="caret"></span>'; } ?>

    <?php if ($promotions) { ?>

        <ul class="dropdown-menu">
            <?php if ($rider_plan_code) { ?><li><a href="#">Rider Plan</a></li><?php } ?>
            <?php if ($low_rate_finance_code) { ?><li><a href="#">Low Rate Finance</a></li><?php } ?>
            <?php if ($custom_promo_code) { ?><li><a href="#"><?php echo $custom_promo_name; ?></a></li><?php } ?>

    <?php } ?>


3 Answers 3


ACF does not return NULL variables, it will return an empty. Try checking with !empty instead of isset.


Are you sure that your 'get_field()' function returns NULL when a field is not set? I think isset is giving you true even if the custom field is empty. The vaule has to be NULL in order to get false. Do a var_dump on a single field when its not set.

var_dump( get_field('rider_plan_code'));
  • this is likely the issue, false is a value. the other potential issue- it sounds like op wants to check if any of them are set, passing multiple vars to isset will only return true if all of them are set.
    – Milo
    Dec 5, 2012 at 16:27
  • get_field() will return false if it doesn't exist
    – Zach
    Dec 5, 2012 at 17:21

From the PHP manual:

If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set. Evaluation goes from left to right and stops as soon as an unset variable is encountered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.