The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Using PHP to hide a div element on a certain page

  • # May 3, 2013 at 9:38 am

    Hi all,

    I was wondering if there is a way to use PHP to hide a div element on a certain page. (I’m using WordPress). I know the quick and easy way is this…

    php if(is_page(50) {
    style type=”text/css”
    #hidethisdiv {
    display: none;
    php } else { };

    However, I need to hide it completely, in other words, hide it from the source code as well. Does anyone know how I can accomplish this?

    I know the code is messed up above, but for some reason I coudln’t get the code to display properly here in the forums.

    # May 3, 2013 at 10:27 am

    This reply has been reported for inappropriate content.

    … if you want to remove the div entirely why not just use something like this:

    if(is_page(‘hide_here’)) {
    //don’t do anything
    } else {
    echo ‘



    # May 3, 2013 at 10:28 am

    I tried, but for some reason I tried to use the code on a post in WordPress and it didn’t work.

    I know WordPress has support forums but I have gotten 0 responses about this, so thought I’d try here.

    # May 3, 2013 at 10:31 am

    Basically what I’m trying to do is put this:

    on the homepage

    I have a wordpress query code, however I needed to just display everything that is just in the blue border. So I figure the only way to do that was to add an exception code in the post…but it wasn’t working when I queried.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed