• Can’t seem to get this to work…

    I have 3 different widgetized sidebars that I’d like to implement, 2 on a certain page, and 1 on any other page.

    First I added my sidebars to the functions.php file:

    <?php
    	if ( function_exists('register_sidebars') )
    	register_sidebars(3);
    ?>

    …and I’m wondering how I give each a name instead of a number?

    I’m setting this up for a client and it will be much easier for them to understand if it said “home sidebar” “store sidebar” etc., instead of “Sidebar 1”, “Sidebar 2” etc.

    So I’m basing my code on this:

    <?php if ( is_home() ) { ?>
    ///code for first sidebar///
    </div>
    <?php } elseif ( is_page(’12’) )
    ///code for second sidebar///
    </div>
    <?php } else { ?>
    ///code for third sidebar///
    <?php } ?>
    <?php endif; ?>

    And combining it with:

    <?php if ( is_home() || !dynamic_sidebar(1) ) : ?>

    And ending up with something that doesn’t work…

    Any ideas or a link to a proper implementation of this idea?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter fitzpatrick512

    (@fitzpatrick512)

    I ended up with an admittedly less elegant solution:

    Since the pages that I wanted to change happened to have their own templates, I was able to just change the call for sidebar.php on each page to call different instances of the sidebar, which in turn call for the custom sidebar I enabled in functions.php

    I added additional sidebar.php files (sidebar-2.php etc.) to the server, and have this code within it.

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

    Then I call his sidebar.-2.php file from the template files like so:

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

    So I got away with a half-assed solution this time, but I’m very interested n something more robust, surprised there isn’t a plugin or it.

    Thread Starter fitzpatrick512

    (@fitzpatrick512)

    Ok, revisiting this issue for another project. I want to combine the following bits of code, in lay terms I want it to do this:

    If it’s the homepage, display the “Homepage Sidebar”, if not, display the other side bar, “Sidebar”/

    <?php
    if (is_home()) {
       the_content();
    }
    else {
       the_excerpt();
    }
    ?>
    
    	<?php genesis_before_sidebar_widget_area(); ?>
    	<?php if (!dynamic_sidebar('Sidebar')) : ?>
    
    		<div class="widget widget_text"><div class="widget-wrap">
    			<h4 class="widgettitle">Sidebar Widget Area</h4>
    			<div class="textwidget"><p><?php printf(__('This is the Sidebar Widget Area. You can add content to this area by visiting your <a href="%s">Widgets Panel</a> and adding new widgets to this area.', 'genesis'), admin_url('widgets.php')); ?></p></div>
    		</div></div>
    
    	<?php endif; ?>
    
    		<?php if (!dynamic_sidebar('Homepage Sidebar')) : ?>
    
    		<div class="widget widget_text"><div class="widget-wrap">
    			<h4 class="widgettitle">Sidebar Widget Area</h4>
    			<div class="textwidget"><p><?php printf(__('This is the Sidebar Widget Area. You can add content to this area by visiting your <a href="%s">Widgets Panel</a> and adding new widgets to this area.', 'genesis'), admin_url('widgets.php')); ?></p></div>
    		</div></div>
    
    	<?php endif; ?>
    
    	<?php genesis_after_sidebar_widget_area(); ?>
    
    </div>

    If you bought Genesis from StudioPress you should have access to the support forums there, where you can get unlimited support from the developers of the theme itself. I think you’ll have much better luck that way.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘using conditionals to implement page specific sidebars’ is closed to new replies.