WordPress.org

Ready to get started?Download WordPress

Forums

Displaying a different header graphic on selected pages (1 post)

  1. Jonas Grumby
    Member
    Posted 5 years ago #

    Hi everyone,

    I've written some code (with some help from Michael Fields) that allows me to display different headers graphics on different pages of a client's site. I'm just wondering if there is a more concise way of coding this because there will ultimately be at least 5 or 6 pages that will have their own specific header graphic. What I have now works fine, but I'm pretty new to PHP scripting and maybe there is a "neater" or "cleaner" way to do this:

    <?php
      if (is_page("disclaimer")) {
      echo '<div id="header" style="background:url(' .  get_bloginfo('url') . '/wp-content/themes/legal-gavel-10/images/top2.jpg) no-repeat bottom; ">';
      } elseif (is_page("about")) {
       echo '<div id="header" style="background:url(' . get_bloginfo('url') . '/wp-content/themes/legal-gavel-10/images/top3.jpg) no-repeat bottom; ">';
      }
     else {
       echo '<div id="header" style="background:url(' . get_bloginfo('url') . '/wp-content/themes/legal-gavel-10/images/top.jpg) no-repeat bottom; ">';
      }
    ?>

    Thanks for any insights.

Topic Closed

This topic has been closed to new replies.

About this Topic