The Conditional Tags are used in the Template files to change what content is displayed and how that content is displayed on a particular page depending on what conditions that page matches. For example, on the Keys Detail Subpage, we want the sidebar to display the Keys book image and the Newsletter Sign Up form, on the ICW Detail Subpage, we want the sidebar to display the ICW book image and the Newsletter Sign Up form.
The argument:
if (is_page(’page-name’) )
-show this on that page-
‘page-name’ is taken from the Page Slug.
Example:
sidebar_newsletter.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <div id="Sidebar"> <div id="Sidebar-in"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <?php if(is_page('cruising-guides') ) { ?> <img src="http://www.storedemo.semi-local.com /wp-content/themes/WPsemi-local/images/ MTW_2up.jpg" alt="2008 MTW:ICW & Keys DVD" width="195" height="270" /> <?php } ?> <?php if(is_page('electronic-charts') ) { ?> <img src="http://www.storedemo.semi-local.com /wp-content/themes/WPsemi-local/images/ 2008dvd_wp_sb.jpg" alt="2008 MTW DVD" width="195" height="270" /> <?php } ?> <?php if(is_page('icw-detail') ) { ?> <img src="http://www.storedemo.semi-local.com /wp-content/themes/WPsemi-local/images/ MTW_front_sb.jpg" alt="2008 MTW:ICW Guide" width="195" height="270" /> <?php } ?> <?php if(is_page('keys-detail') ) { ?> <img src="http://www.storedemo.semi-local.com /wp-content/themes/WPsemi-local/images/ KEYS_front_sb.jpg" alt="2008 MTW:Keys Guide" width="195" height="270" /> <?php } ?> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar_charts') ) : ?> <?php endif; ?> <?php endif; ?> </div><!-- end #sidebar-in --> </div><!-- end #Sidebar --> |
Replace “sidebar.php” with this string at the bottom of the appropriate page file to make the call for the dynamic sidebar:
<?php include ('sidebar_newsletter.php'); ?>
See also:
Wordpress Codex-Conditional Tags