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 have a meta box checkbox, you click to turn on/show the blow info basically...

These conditionals dont seem to be working for some reason, the first if works, but when i add in any other else if it breaks..

<ul>

    <?php if (get_post_meta($post->ID, 'hm_check_image1', true)) { ?>


    <li>
        stufff stuff other meta info...
    </li>


    <?php elseif (get_post_meta($post->ID, 'hm_check_image2', true)) { ?>

    <li>
        stufff stuff other meta info...
    </li>


    <?php elseif (get_post_meta($post->ID, 'hm_check_image3', true)) { ?>

    <li>
        stufff stuff other meta info...
    </li>


    <? } else { ?>
<!--no checkbox ticked-->

    <?php } ?>

</ul>

I'm obviously missing something obvious, i prefer doing them like this usually so gives me flexibility to put anything i want between the li tags... not just limited by echo.

Any help would be great, sure its a quick one..

share|improve this question
    
Please turn on debugging with defined( 'WP_DEBUG', true ); in your wp-config.php file. This will avoid a lot of those questions for you. –  kaiser Dec 20 '12 at 8:41
add comment

closed as off topic by kaiser, brasofilo, toscho Dec 20 '12 at 11:20

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 0 down vote accepted

This is not really a WordPress Question, as you made a basic PHP mistake, but I'll help you anyway ;)

you forgot to close the conditional with an } before the elseif statements.

This should work:

<ul>

    <?php if (get_post_meta($post->ID, 'hm_check_image1', true)) { ?>


    <li>
        stufff stuff other meta info...
    </li>


    <?php } else if (get_post_meta($post->ID, 'hm_check_image2', true)) { ?>

    <li>
        stufff stuff other meta info...
    </li>


    <?php } else if (get_post_meta($post->ID, 'hm_check_image3', true)) { ?>

    <li>
        stufff stuff other meta info...
    </li>


    <? } else { ?>
<!--no checkbox ticked-->

    <?php } ?>

</ul>
share|improve this answer
    
Whoops, sorry. Thank you though :) –  user4630 Dec 20 '12 at 8:09
add comment

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