• Resolved john_bryan

    (@john_bryan)


    So I’m not entirely new to wordpress, however, I’ve really only worked with one theme over the past year. I’ve made some theme modifications in the past and I’m fairly comfortable with php/css/html. The theme that I’ve worked with always had an option to select which sidebar to use for the page (when creating a new page or editing an existing page).

    I’ve got a new client that wanting to add a few new sections for different restaurant locations and he wants a seperate sidebar for each location subsection. I appears that the company he hired to create this website used (or created) a theme which only supports one sidebar. I’ve registered another sidebar with no issues in the functions.php file, but, I don’t yet have ssh or ftp access to the server to actually add new php files.

    When new sidebar-*.php files are added, does this option to select which sidebar to use automatically appear or will I have to make a seperate template file (or edit page.php)? I’m not quite sure if this is something built into the core of wordpress or simply the theme that I’ve used in the past.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Vadonis

    (@illusionstardev)

    If there is room enough for an extra sidebar, it should appear once the files are updated and widgets are added.

    Ken Lewis

    (@trinity13)

    Are you wanting one sidebar on one page and a different sidebar on another?

    If so, then you are going to need to make a template for the new sidebar and assign the new template to the pages that requires the new sidebar.

    Thread Starter john_bryan

    (@john_bryan)

    Yes Trinity13, the client has a restaurant with a few different locations. Each location has its own specials and events, etc.. I would like to keep the main navigation the same throughout and have a different sidebar for each location sub section.

    In the other theme I used (abrax) there was simply an option on the page edit screen to select which sidebar to use for which page. All I needed to do was register a new one in functions.php and and I was good to go with just the single sidebar.php in my theme folder.

    I’ve never made a theme before so I’m not totally familiar with the ins and outs wordpress.

    When you say that I need to make a new template for the sidebar, do you mean a sidebar-2.php or something like that? Or do you mean that I would need to create a new page template that calls something like get_sidebar(‘sidebar-2’);?

    This theme is quite a bit simpler than the one I’ve worked with in the past so hopefully it will give me an opportunity to learn a bit more wordpress.

    Here is my current sidebar.php if it is of any help:

    <div id="sidebar" class="grid_8">
    					<div class="gutter20">
    
    					<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>
    <?php endif; ?>
    
    					</div>
    				</div><!-- end sidebar -->
    				<div class="clear"></div>

    and here is my functions.php:

    <?php
    // SIDEBAR
    if ( function_exists('register_sidebar') ) {
       register_sidebar(array(
           'before_widget' => '<li id="%1$s" class="widget %2$s">',
           'after_widget' => '</li>',
           'before_title' => '<h2 class="widgettitle">',
           'after_title' => '</h2>',
       ));
    }
    
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'name' => 'location2',
    'id' => 'location2',
    'description' => 'Sidebar for location2',
    'before_widget' => '<div style="height: 280px"></div><li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',
    ));
    }
    
    // CUSTOM MENUS
    if ( function_exists( 'register_nav_menus' ) ) {
    	register_nav_menus(
    		array(
    		  'pluginbuddy_mobile' => 'PluginBuddy Mobile Navigation Menu',
    		  'foot_menu' => 'My Custom Footer Menu'
    		)
    	);
    }
    
    // EXCERPT
    function new_excerpt_length($length) {
    	return 20;
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    
    function new_excerpt_more($more) {
           global $post;
    	return ' <a class="excerpt-more" href="'. get_permalink($post->ID) . '">' . 'More&raquo;' . '</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    
    // Add Read More link to manual excerpts.
    add_action('the_excerpt', 'child_add_manual_read_more', 20);
    function child_add_manual_read_more($excerpt) {
        if ( has_excerpt() ) {
            // Trim the newline.
            $excerpt = rtrim($excerpt);
            // Check for the <p> tags
            if ( '<p>' == substr($excerpt, 0, 3) && '</p>' == substr($excerpt, -4) )
                $excerpt = sprintf( '<p>%s <a href="%s" rel="nofollow" class="morelink">More»</a></p>', substr($excerpt, 3, -4), get_permalink() );
        }
        return $excerpt;
    }
    ?>

    location2 is the sidebar that I just registered but have yet to make a template file.

    Ken Lewis

    (@trinity13)

    Just copy your existing page.php rename it and put this at the top:

    /**
     * Template Name: Template with sidebar 2
     */

    and then swap out the sidebar for another one.

    Then for the page you want the sidebar, select the template above.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sidebar selection option in theme’ is closed to new replies.