• I have some elements that i hide using css display: none; functions, and most ones i hide using javascript, but when ever a user stripes or disables his browser css and javascript everything i hide will become visible on the front end, though the site may be looking scattered rhen but those hidden elements will still show as html files..
    Any idea on how to hide such elements so that if javascript and css are disabled in the viewers browser the hidden elements won’t still show.
    I was thinking php can be used since there is no way to strip it off.

Viewing 3 replies - 1 through 3 (of 3 total)
  • It is possible several different ways using PHP. But you need to know what conditions you want to hide on.

    As a very simple example…

    if (condition_to_b_true ()) }
        echo '<p>Show content in here</p>';
    }
    Thread Starter pandglobal

    (@pandglobal)

    Nice, but I don’t know really how to create a condition, can I have it simply conditioned to be hidden and never show at all?
    And that place the echo showing the html code, I want to put a div id that is written in an html elsewhere,……….

    if (condition_to_b_true ()) }
    echo ‘#id_of_the_div’;
    }

    So which condition should i set and how do I set or call the condition.

    If you want to have that area never shown at all, just remove it from the template that’s being used (in a child theme of course). There’s no need to do anything more if you want something 100% gone.

    For placing the div somewhere, you’re right, but I can’t tell you what the condition for the if() is. There’s literally millions of things that it could be, and without knowing what you actually want there’s no possible way for anyone to tell you what to use there.

    It sounds like you need to go back a few steps and see what you want to do, and then work forward step-by-step.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide elements using php’ is closed to new replies.