• Hi

    I am usin alltuts theme. I have added a new sidebar according to wordpress tutorial (codex)
    I have been following this guide: http://codex.wordpress.org/Customizing_ … g_sidebars

    The code that already was in function.php was this:

    <div class="rightBoxTop"></div>
    <div class="rightBoxMid">',
    'after_widget' => '</div>
    <div class="rightBoxBottom"></div>
    </div>',
    'before_title' => '<h2>',
    'after_title' => '</h2>',
    ));
    
    register_sidebar(array(
    'name' => 'footer',
    'before_widget' => '<div class="boxFooter">',
    'after_widget' => '</div>',
    'before_title' => '<h2>',
    'after_title' => '</h2>',
    ));

    1. I added this:

    register_sidebar(array(
       'name' => '2',
    'before_widget' => '<div class="rightBox">
             <div class="rightBoxTop"></div>
             <div class="rightBoxMid">',
       'after_widget' => '</div>
             <div class="rightBoxBottom"></div>
          </div>',
       'before_title' => '<h2>',
       'after_title' => '</h2>',
    ));

    2. I created a file called sidebar2.php and copied the code in sidebar.php and pasted it in sidebar2.php and added: <?php
    if (!function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘2’)) : //
    ?> i sidebar2.php

    3. Pasted following code in page.php:
    <?php get_sidebar (‘2’); ?>

    Well…. It didn´t work..

    Anyone who is smart and could help me? Would really appriciate it!

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • I believe WP will be looking for sidebar-2.php, not sidebar2.php

    Thread Starter Jaegerstickan

    (@jaegerstickan)

    I changed it, but that didn´t work. It fetched to normal sidebar. I am getting crazy here…

    Does the registering work in functions.php?

    IN the widgets menu, does it show up and allow you to add widgets to it?

    Thread Starter Jaegerstickan

    (@jaegerstickan)

    Yes it works.. Maybe it is this code that i wrong in sidebar-2.php:

    <?php
    if (!function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘2’)) : //
    ?>

    I remove it: the normal sideshow comes up. I add it, the pages have no sidebar at all and the slideshow that I have on all pages breaks.. It is strange..

    all that code says is if the dynamic sidebar function does not exist, or if there is no dynamic sidebar name 2, do something.

    Normally after that you would have some code for some default widgets to be displayed if no widgets are installed

    See if anything here,
    http://vudu.me/qq

    or here,
    http://vudu.me/k

    Helps you out at all? Those are 2 posts I have about adding sidebars, or adding widget areas

    <?php dynamic_sidebar( '2' ); ?>

    might work?

    Thread Starter Jaegerstickan

    (@jaegerstickan)

    Yeah, I have code after that already. Copied sidebar.php So this is what I have in sidebar-2.php:

    <?php
    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('2')) : //
    ?>
    <!-- Begin #colRight -->
    		<div id="colRight">
    
    		<?php if(get_option('alltuts_ads') == 'yes'){?>
    		<!-- Begin Ads -->
    
    						<!-- end ads -->
    				<a href="<?php echo get_page_link(get_option('alltuts_advertise'));?>" class="advertise">&raquo; Advertise with us!</a>
    				</div>
    				<div class="rightBoxBottom"></div>
    			</div>
    		<!-- End Ads -->
    		<?php }?>
    
    		<?php if(get_option('alltuts_twitter_user')!="" && get_option('alltuts_latest_tweet')!="no"){ ?>
    		<!-- Begin #twitter -->
    				<div id="twitter">
    						<div id="twitter_update_list">
    						</div>
    					<div id="bottom"><a href="http://twitter.com/<?php echo get_option('alltuts_twitter_user'); ?>">Follow Us on Twitter!</a></div>
    				</div>
    		<!-- End #twitter -->
    		<?php } ?>
    
    		<?php /* Widgetized sidebar */
    	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?><?php endif; ?>
    
    		</div>
    		<!-- End #colRight -->
    		<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
    		<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/<?php echo get_option('alltuts_twitter_user'); ?>.json?callback=twitterCallback2&count=<?php
    		if(get_option('alltuts_number_tweets')!=""){
    			echo get_option('alltuts_number_tweets');
    			}else{
    				echo "1";
    			} ?>"></script>

    where is that code in yours?

    in yours I see

    !dynamic_sidebar('2'))

    in mine I have

    dynamic_sidebar( '2' );

    notice, no exclamation mark !!!!

    THat is an important difference

    Thread Starter Jaegerstickan

    (@jaegerstickan)

    Yes, you are right thats a big diffrence!

    I have now change it so this is what I have in my sidebar-2.php, but it still doesn´t work..

    <?php
    if (!function_exists('dynamic_sidebar') || dynamic_sidebar( '2' ); ?>
    <!-- Begin #colRight -->
    		<div id="colRight">
    
    		<?php if(get_option('alltuts_ads') == 'yes'){?>
    		<!-- Begin Ads -->
    
    						<!-- end ads -->
    				<a href="<?php echo get_page_link(get_option('alltuts_advertise'));?>" class="advertise">&raquo; Advertise with us!</a>
    				</div>
    				<div class="rightBoxBottom"></div>
    			</div>
    		<!-- End Ads -->
    		<?php }?>
    
    		<?php if(get_option('alltuts_twitter_user')!="" && get_option('alltuts_latest_tweet')!="no"){ ?>
    		<!-- Begin #twitter -->
    				<div id="twitter">
    						<div id="twitter_update_list">
    						</div>
    					<div id="bottom"><a href="http://twitter.com/<?php echo get_option('alltuts_twitter_user'); ?>">Follow Us on Twitter!</a></div>
    				</div>
    		<!-- End #twitter -->
    		<?php } ?>
    
    		<?php /* Widgetized sidebar */
    	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?><?php endif; ?>
    
    		</div>
    		<!-- End #colRight -->
    		<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
    		<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/<?php echo get_option('alltuts_twitter_user'); ?>.json?callback=twitterCallback2&count=<?php
    		if(get_option('alltuts_number_tweets')!=""){
    			echo get_option('alltuts_number_tweets');
    			}else{
    				echo "1";
    			} ?>"></script>

    And in function:

    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    	'name' => 'sidebar1',
    	'before_widget' => '<div class="rightBox">
    			<div class="rightBoxTop"></div>
    			<div class="rightBoxMid">',
    	'after_widget' => '</div>
    			<div class="rightBoxBottom"></div>
    		</div>',
    	'before_title' => '<h2>',
    	'after_title' => '</h2>',
    ));
    
    register_sidebar(array(
    	'name' => 'footer',
    	'before_widget' => '<div class="boxFooter">',
    	'after_widget' => '</div>',
    	'before_title' => '<h2>',
    	'after_title' => '</h2>',
    ));
    
    register_sidebar(array(
    	'name' => '2',
    'before_widget' => '<div class="rightBox">
    			<div class="rightBoxTop"></div>
    			<div class="rightBoxMid">',
    	'after_widget' => '</div>
    			<div class="rightBoxBottom"></div>
    		</div>',
    	'before_title' => '<h2>',
    	'after_title' => '</h2>',
    ));

    And this on page.phph:

    <?php get_sidebar(2); ?>

    OK, I am confused as to what all is going on here….

    Are you trying to have it display what you have coded into the sidebar-2.php, or do you want to use widgets?

    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar( '2' ); ?>

    Put the ! back in there I think. I was trying to go a different route, but I’m gonna try to work with what you have.

    Now, toward the bottome of the sidebar-2.php you have

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

    Why is that there? Is that intentional?

    Basically you have 2 if statements in that sidebar file, and one endif.

    Is that the entirety of your code? I’m just wondering what the 2 if statements are for? One is talking about sidebar-2 and one is talking about sidebar

    Thread Starter Jaegerstickan

    (@jaegerstickan)

    That is of course the problem! I removed this: if (!function_exists('dynamic_sidebar') || !dynamic_sidebar( '2' ); ?>

    And putted ‘2’ in the bottom statement instead: if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?><?php endif; ?>

    And now it works.
    Thanks for looking at it with your eyes!

    Sure, I missed that the first time I looked at it

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Is anyone smart out there?’ is closed to new replies.