• Resolved RSimpson

    (@rsimpson)


    Hi folks,

    I’ve got a conditional checking for the existence of a custom field called “hide_sub_navigation”. Now you’ve probably got a good idea of what this custom field is meant to do, if the field exists hide the sub menu.

    Here’s why it’s strange (either that or I haven’t fully woken up yet), going by my code it’s working but the wrong way round if you get what I mean. Get a load of this:

    <?php if(post_custom('hide_sub_navigation')) {?>
    <ul id="sub_navigation">
    <?php
    // Code to load sub level navigation.
    ?>
    </ul>
    <?php
    } else {
    // do nothing
    }?>

    This code actually hides it when the field is true, whereas when I read the code it should actually show it when it’s true.

    Can anybody see what’s going on there? It appears to be contradicting itself.

    Cheers,
    Robert

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter RSimpson

    (@rsimpson)

    OK, it turns out that it’s not actually working at all. It’s ignoring the custom field and I’m really confused.

    Thread Starter RSimpson

    (@rsimpson)

    Bugger it, I’ve just gone back to the old way of doing it and it’s working as expected now.

    Enjoy

    <?php
    $hide_sub_navigation = get_post_meta($post->ID, 'hide_sub_navigation', true);
    if($hide_sub_navigation == FALSE) {
    ?>
    <ul id="sub_navigation">
    <?php
    // Code to load sub level navigation.
    ?>
    </ul>
    <?php
    } else {
    // do nothing
    }
    ?>

    I was having exactly the same problem too, but your final method fixed it just fine. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘custom fields acting strange’ is closed to new replies.