• autumnsky

    (@autumnsky)


    Could someone please help me with this? For some reason I can’t get the coding right to display different sidebars for different pages.

    <div id="sidebars">
    
    <div class="widgetize">
    
    <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar() ) : ?>
    
    <?php if(is_home()) { ?>
    
      <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">S</span>earch</h2>
    
    	<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    
    	<p id="sb"><input name="s" type="text" id="s" value="<?php echo wp_specialchars($s, 1); ?>"/></p>
    
    	<p id="sk"><input name="submit" type="image" id="submit"  value="." src="<?php bloginfo('stylesheet_directory'); ?>/images/s.gif" /></p>
    
    	</form>
    
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <div class="box">
    <div class="topbox"></div>
    <div class="ulbox">
    <h2><span class="pink">A</span>bout Me</h2>
    <p>Linda Belle stirs up trouble in Sherwood Forest, hangs out with Adrian Monk solving crimes, and may or may not be the half-sister of George Michael Blueth. She's an avid reader and a compulsive writer. In her spare time she organizes her novels and sneers at Stephanie Meyers. <strong>And right now she is...</strong></p>
    <ul id="twitter_update_list"></ul>
    <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
    <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/SilverArrow.json?callback=twitterCallback2&count=5"></script>
    
    <div align="center"><script type="text/javascript">
    zg_insert_badge = function() {
    var zg_bg_color = '333333';
    var zgi_url = 'http://www.flickr.com/apps/badge/badge_iframe.gne?zg_bg_color='+zg_bg_color+'&zg_person_id=23401189%40N02';
    document.write('<iframe style="background-color:#'+zg_bg_color+'; border-color:#'+zg_bg_color+'; border:none;" width="113" height="151" frameborder="0" scrolling="no" src="'+zgi_url+'" title="Flickr Badge"><\/iframe>');
    }
    zg_toggleWhat = function() {
    document.getElementById('zg_whatdiv').style.display = (document.getElementById('zg_whatdiv').style.display != 'none') ? 'none' : 'block';
    document.getElementById('zg_whatlink').style.display = (document.getElementById('zg_whatdiv').style.display != 'none') ? 'none' : 'block';
    return false;
    }
    </script>
    <div class="zg_div"><div class="zg_div_inner">
    <script type="text/javascript">zg_insert_badge();</script>
    <div id="zg_whatdiv">This is a Flickr badge showing public photos and videos from <a href="http://www.flickr.com/photos/23401189@N02">ransomher</a>. Make your own badge <a href="http://www.flickr.com/badge.gne">here</a>.</div>
    <script type="text/javascript">if (document.getElementById) document.getElementById('zg_whatdiv').style.display = 'none';</script></div>
    </div>
    </div>
    
    </div>
    <div class="bottombox"></div>
    </div>
    
      <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">L</span>atest Entries</h2>
    	<ul class="arrow">
    	<?php get_archives('postbypost', 5); ?>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
      <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">R</span>ecent Comments</h2>
    	<ul class="arrow">
        <?php if(function_exists("get_recent_comments")) : ?>
        <?php get_recent_comments(); ?>
        <?php else : ?>
        <?php mw_recent_comments(10, false, 50, 50, 35, 'all', '<li><a href="%permalink%" title="%title%"><font color="#cccccc">%date%</font> | %author_name% in %title%</a></li>','d.m'); ?>
       <?php endif; ?>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
      <?php if(function_exists("get_mostcommented")) : ?>
      <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">H</span>ot Entries</h2>
    	<ul class="arrow">
    	<?php get_mostcommented(); ?>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
      <?php endif; ?>
    
      <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">A</span>rchives</h2>
    	<ul class="arrow">
        <?php wp_get_archives('type=monthly&show_post_count=0'); ?>
    	</ul><br />
    
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <?php } ?>
    
    <?php if(is_page('5') || is_page('139') || is_page('159') || is_page('143') || is_page('144') || is_page('203')) { ?>
    
     <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">A</span>uthor</h2>
    	<ul class="arrow">
        </li>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <?php } ?>
    
    <?php if(is_page('138')) { ?>
    
     <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">B</span>ooks</h2>
    	<ul class="arrow">
        </li>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <?php if(is_page('0') || is_page('0')) { ?>
    
     <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">M</span>eta</h2>
    	<ul class="arrow">
        </li>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <?php } ?>
    
    <?php if(is_page('100') || is_page('84') || is_page('134') || is_page('17') || is_page('95') || is_page('29') || is_page('31') || is_page('32') || is_page('24')) { ?>
    
     <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">P</span>ortfolio</h2>
    	<ul class="arrow">
        </li>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <?php } ?>
    
    <?php if(is_page('8')) { ?>
    
     <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">D</span>ownloads</h2>
    	<ul class="arrow">
        </li>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <?php } ?>
    
    <?php if(is_page('152') || is_page('149') || is_page('193') || is_page('195') || is_page('72') || is_page('73') || is_page('196') || is_page('192')) { ?>
    
     <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">S</span>ite</h2>
    	<ul class="arrow">
        </li>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    <?php } ?>
    
      <div class="box">
        <div class="topbox"></div>
    	<div class="ulbox">
    	<h2><span class="pink">M</span>eta</h2>
    	<ul class="arrow">
        <?php wp_meta(); ?>
        <?php wp_register(); ?>
        <li><?php wp_loginout(); ?></li>
        <li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.'); ?>"><abbr title="WordPress">Wordpress</abbr></a></li>
    	</ul>
    	</div>
    	<div class="bottombox"></div>
      </div>
    
    </div>
    
    </div>
Viewing 3 replies - 1 through 3 (of 3 total)
  • eyephoto

    (@eyephoto)

    You might have some
    <?php endif; ?> missing?

    Grapho

    (@grapho)

    I see a lot of if if if, and no endif.

    Also, I believe using elseif is better practice than using if’s for everything. I am not a great programmer, but if i understand correctly, when the code is read and it goes through the first “if” and it returns a false, it will end the code when there is no elseif or endif… Therefore the rest of your code (i.e. the other if’s) won’t even get read.

    garbonzo

    (@garbonzo)

    Your code is being ignored.

    The line `<?php if ( !function_exists(‘dynamic_sidebar’)
    || !dynamic_sidebar() ) : ?>`

    is saying, that IF the dynamic sidebar is not available or being used, then do all the stuff you wrote. Unless you’ve done something to your wordpress’s core, the dynamic sidebar is available and working. Which means everything you wrote after that line is ignored.

    But I think you want to able to use the dynamic sidebars as well as all your code, so do EyePhoto’s suggestion and put an endif, here:

    <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar() ) : endif; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bloody sidebar is messed up!’ is closed to new replies.