Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. Hi Joern,

    More on this I'm afraid - I can't quite seem to format the tags for a series of conditional tags.

    What I want is different sidebar ads depending on the page (e.g. some will be different ads for blog categories, some for individual pages, etc).

    For that reason I think I need to create a set of conditions such as below, but using this gives me a parsing error. Any chance you could give me a pointer?

    Thanks again.

    Dr_Whom

    <div id="sidebar">
    
    <div id="sidebar-ads">
    <?php if ( is_page('Favourbrook') ) { ?>
    <a href="http://www.iamstaggered.com"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/testadvertsidebar.png" alt="" width="300px" height="250px"  /></a><?php } elseif <?php if ( is_category('randallmurrow') ) { ?>
    <a href="http://weddings.randallmurrow.com/"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/randallad.jpg" alt="" width="300px" height="250px"  /></a><?php } else { ?>
    <a href="http://www.iamstaggered.com/forum/challenge-staggered/how-does-it-work">
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/Ateam11.png" alt="" width="300px" height="250px" />
    </a><?php } ?>
    
    </div>
    
    <div id="sidebar-top">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
    
    <?php endif; ?>
    </div>
    
    <div id="sidebar-middle" class="clearfloat">
    <div id="sidebar-left">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
    <?php endif; ?> 
    
    <ul><?php wp_list_bookmarks('categorize=0&category=17&title_li=0&show_images=0&show_description=0&orderby=name'); ?></ul>
    </div>  
    
    <div id="sidebar-right">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(3) ) : ?> 		
    
    <h3>Blogroll</h3>
    
    <ul>
    <li><a href="http://colorlabsproject.com">Colorlabs Project</a></li>
    <li><a href="http://michaelhutagalung.com">Michael Jubel</a></li>
    <li><a href="http://www.hannasyalala.com">Hanna Siahaan</a></li>
    <li><a href="http://majarimagazine.com">Majari Magazine</a></li>
    <li><a href="http://bloggerzine.majarikanayakan.com">The Bloggerzine</a></li>
    <li><a href="http://www.majarikanayakan.com">Majari Kanayakan</a></li>
    </ul>
    <?php endif; ?>
    </div> 
    
    </div>
    
    <div id="sidebar-bottom">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(4) ) : ?>
    <?php endif; ?> </div>   
    
    </div>
    Posted 5 months ago #
  2. you got a typing error "elseif <?php if"
    this should work:

    <?php if ( is_page('Favourbrook') ) { ?>
    <a href="http://www.iamstaggered.com" onClick="javascript: pageTracker._trackPageview('/outgoing/www.designaventure.co.uk');"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/testadvertsidebar.png" alt="" width="300px" height="250px"  /></a>
    <?php } elseif ( is_category('randallmurrow') ) { ?>
    <a href="http://weddings.randallmurrow.com/"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/randallad.jpg" alt="" width="300px" height="250px"  /></a>
    <?php } elseif ( is_category('anyothercat') ) { ?>
    anyothercat thing
    <?php } elseif ( is_tag('stag-do') ) { ?>
    thing for tag stag-do
    <?php } else { ?>
    <a href="http://www.iamstaggered.com/forum/challenge-staggered/how-does-it-work">
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/Ateam11.png" alt="" width="300px" height="250px" />
    </a>
    <?php } ?>
    Posted 5 months ago #
  3. Brilliant - thank-you!

    Posted 5 months ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):