title: Wordpress is_page
body: <p>I am trying to have a div with an a tag which goes to a page in wordpress. When I go to the page, and a tag has a class of "active". </p>
  
  <p>At the moment I am using this</p>
  
  <pre><code>&lt;?php if( is_page(( 'policy') )   ) { 
    echo '&lt;div id="policy"&gt;&lt;a href="http://localhost:8888/xxx/yyy" class="active"&gt;Delivery, Returns &amp; Sustainability&lt;/a&gt;&lt;/div&gt;';
    } else {
        echo '&lt;div id="policy"&gt;&lt;a href="http://localhost:8888/xxx/yyy"&gt;Delivery, Returns &amp; Sustainability&lt;/a&gt;&lt;/div&gt;';
  
     } ?&gt;
  </code></pre>
  
  <p>So when you visit the front page, there is no active class on the link (which is good). When you go to the policy page, it goes active (also good). However, if you go to another page after visiting policy the link stays "active" until the browser is refreshed.</p>
  
  <p>Thanks!</p>
  
  <p>More Code</p>
  
  <p>This is my footer.php</p>
  
  <pre><code>  &lt;/div&gt;&lt;!-- #change Close --&gt;
  
  
    &lt;?php if( is_page('policy')) { 
    echo '&lt;div id="policy"&gt;&lt;a href="http://localhost:8888/oakandhide/policy" class="active"&gt;Delivery, Returns &amp; Sustainability&lt;/a&gt;&lt;/div&gt;';
    } else {
        echo '&lt;div id="policy"&gt;&lt;a href="http://localhost:8888/oakandhide/policy"&gt;Delivery, Returns &amp; Sustainability&lt;/a&gt;&lt;/div&gt;';
  
     } ?&gt;
  
  
     &lt;ul id="footer-icons"&gt;  &lt;li&gt;&lt;a href="#"&gt;&lt;i class="icon-instagram"&gt;&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="#"&gt;&lt;i class="icon-facebook"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;i class="icon-twitter"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="#"&gt;&lt;i class="icon-pinterest"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
  
  
  
  
  
  
  
  
    &lt;?php 
    // Hide/Show footer logic
    if (is_search() || is_page('Search')) {
      if ($search_display_footer) {
        include('snippets/footer-columns.php');
      } else {
        echo '&lt;div id="footer"&gt;&lt;/div&gt;';
      }
    } else if (is_home()) {
      if ($frontpage_display_footer) {
        include('snippets/footer-columns.php');
      } else {
        echo '&lt;div id="footer"&gt;&lt;/div&gt;';
      }
    } else if (is_category()) {
      if (get_field('display_footer', $taxonomy . '_' . $term_id)) {
        include('snippets/footer-columns.php');
      } else {
        echo '&lt;div id="footer"&gt;&lt;/div&gt;';
      }
    } else if (is_tag()) {
      if ($display_footer) {
        include('snippets/footer-columns.php');
      } else {
        echo '&lt;div id="footer"&gt;&lt;/div&gt;';
      }
    } else {
      if (get_field("page_template") == 'Inherit Category') {
        $display_footer = get_field('display_footer', $taxonomy . '_' . $term_id);
        if ($display_footer) {
          include('snippets/footer-columns.php');
        } else {
          echo '&lt;div id="footer"&gt;&lt;/div&gt;';
        }
      } else if (get_field("page_template") == 'Custom') {      
        if (get_field("display_footer")) {
          include('snippets/footer-columns.php');
        } else {
          echo '&lt;div id="footer"&gt;&lt;/div&gt;';
        }
      } else {
        include('snippets/footer-columns.php');
      }
    } ?&gt;
  
  &lt;/div&gt;&lt;!-- #wrap Close --&gt;
  
  &lt;?php wp_footer(); ?&gt;
  
  
  &lt;!-- jQuery the Faery --&gt;
  &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;window.jQuery || document.write('&lt;script type="text/javascript" src="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/jquery-1.10.2.min.js"&gt;&lt;\/script&gt;')&lt;/script&gt;
  &lt;!--[if !IE]&gt; --&gt;
  &lt;script src="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/jquery.history.js"&gt;&lt;/script&gt;
  &lt;!-- &lt;![endif]--&gt;
  &lt;!--[if gte IE 8]&gt;
  &lt;script src="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/jquery.history.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;
  &lt;!--[if lt IE 9]&gt;
  &lt;script src="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/css3-mediaqueries.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;
  &lt;script&gt;
    // Setting variables (so they are available to ui.min.js)
      // Layout
    var toggle_menu_speed = &lt;?php echo $toggle_menu_speed; ?&gt;;
    var taxonomy_pagination_type = '&lt;?php echo $taxonomy_pagination_type; ?&gt;';
    var max_site_width = &lt;?php echo $max_site_width; ?&gt;;
    var site_left_right_border_margin = &lt;?php echo $site_left_right_border_margin; ?&gt;;
    var site_margin_left = '&lt;?php echo $site_margin_left; ?&gt;';
    var site_margin_right = '&lt;?php echo $site_margin_right; ?&gt;';
    var link_decoration = '&lt;?php echo $link_decoration; ?&gt;';
      // History
    var history_state = &lt;?php if ($history_state) { echo $history_state; } else {echo 0;} ?&gt;;
    &lt;?php if ($history_state) { ?&gt;
    var history_transition_speed = &lt;?php echo $history_transition_speed; ?&gt;;
    var history_transition_delay = &lt;?php echo $history_transition_delay; ?&gt;;
    var history_color_transition_speed = &lt;?php echo $history_color_transition_speed; ?&gt;;
    var history_cache = '&lt;?php if ($history_cache) {echo $history_cache;} ?&gt;';
    var page_loader = '&lt;?php if ($page_loader) {echo $page_loader;} else {echo 'None';} ?&gt;';
    &lt;?php if ($page_loader == 'Type-5') { ?&gt;
    var page_loader_text = '&lt;?php echo $page_loader_text; ?&gt;';
    var page_loader_text_size = '&lt;?php echo $page_loader_text_size; ?&gt;';
    &lt;?php } ?&gt;
    &lt;?php } ?&gt;
      // Interface
    var masonry_library = '&lt;?php echo $masonry_library; ?&gt;';
    var mobile_toggle_menu_speed = &lt;?php echo $mobile_toggle_menu_speed; ?&gt;;
    var tablet_toggle_menu_speed = &lt;?php echo $tablet_toggle_menu_speed; ?&gt;;
    var default_easing = '&lt;?php echo $default_easing; ?&gt;';
    var image_loaded_fade_speed = &lt;?php echo $image_loaded_fade_speed; ?&gt;;
    var slideshow_speed = &lt;?php echo $slideshow_speed; ?&gt;;
    var post_next_previous_keys = &lt;?php if ($post_next_previous_keys) { echo $post_next_previous_keys; } else {echo 0;} ?&gt;;
    var focus_mode_margin_top = &lt;?php echo $focus_mode_margin_top; ?&gt;;
    var focus_mode_margin_bottom = &lt;?php echo $focus_mode_margin_bottom; ?&gt;;
      // Copy
    var copy_6 = '&lt;?php if ($copy_6) {echo $copy_6;} else {echo 'Loading...';} ?&gt;';
      // Mobile
    var mobile_thumbnails_force_hover = &lt;?php if ($mobile_thumbnails_force_hover) { echo $mobile_thumbnails_force_hover; } else {echo 0;} ?&gt;;
      // Tablet
    var tablet_thumbnails_force_hover = &lt;?php if ($tablet_thumbnails_force_hover) { echo $tablet_thumbnails_force_hover; } else {echo 0;} ?&gt;;
  &lt;/script&gt;
  
  &lt;script src="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/plugins.min.js"&gt;&lt;/script&gt;
  &lt;script src="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/jquery.flexslider-min.js"&gt;&lt;/script&gt;
  
  &lt;script src="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/ui.min.js"&gt;&lt;/script&gt;
  &lt;!-- Insert Google Analytics if set --&gt;
  &lt;?php if (get_field('analytics_code_snippet', 'option')) {
    echo get_field('analytics_code_snippet', 'option');
  } ?&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>