WordPress.org

Ready to get started?Download WordPress

Forums

Modify PHP to exclude widgets on certain pages? (2 posts)

  1. a_johnson
    Member
    Posted 4 years ago #

    My template has bottom.php which is used for the display of three columns of widgets. I have several pages that I don't want to display the three columns of widgets at the bottom of the page. The code in the Main Index Template that calls the bottom.php is this:

    <?php endif; ?>
    <?php include (TEMPLATEPATH . "/bottom.php"); ?>

    The following is on the header.php file for displaying the slideshow on the front page only. Can this be adapted to allow everything but two pages or exclude two pages but allow everything else?

    <?php /* If this is home */ if (is_front_page()) { ?>
    <?php include (TEMPLATEPATH . '/slideshow.php'); ?>
    <?php } ?>

    <?php if ( $paged > 1 ) { ?>
    <?php } ?>

    Any help is appreciated.

  2. Edward Caissie
    Theme Review Admin
    Posted 4 years ago #

    You should be able to make use of the is_page() conditional, here is a link to the codex page: http://codex.wordpress.org/Function_Reference/is_page

    Look at something along the lines of:

    <?php
      if (is_page(array(42,'about-me','Contact')))
      {
        include (TEMPLATEPATH . "/bottom.php");
      }
      endif;
    ?>

    So, when the page displayed is either post ID 42, or post_name "about-me", or post_title "Contact" the bottom.php file will be included.

    You can also use '!is_page()' to not include bottom.php as well.

Topic Closed

This topic has been closed to new replies.

About this Topic