Forums

PHP script - cause sidebar div to display only on index.php (2 posts)

  1. matt1027
    Member
    Posted 2 years ago #

    I have some divs in a sidebar.php template that I only want to appear on the index.php page, not on other pages like single or archive. I'm trying to use something like these scripts in the sidebar.php template but they're not working.

    <?php if ($_SERVER['SCRIPT_NAME'] == '/index.php'): ?>
    <div>
    </div>
    <?php endIf; ?>

    or

    <?php if ( $_SERVER['PHP_SELF'] == '/index.php' ) { ?>
    <div>
    </div>
    <?php } ?>

    Can anyonoe tell me how to do this? Thanks!

  2. Otto
    Tech Ninja
    Posted 2 years ago #

    Read this:
    Conditional Tags

    if (is_home()) :
    ...
    endif;

Topic Closed

This topic has been closed to new replies.

About this Topic