• Resolved theplastickid

    (@theplastickid)


    Can anyone tell me how to add a second dynamic sidebar to my template I am using the Starkers them here: https://elliotjaystocks.com/starkers/

    And this is the code in my functions.php file

    <?php
    /**
     * @package WordPress
     * @subpackage Starkers
     */
    
    automatic_feed_links();
    
    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>',
    	));
    }
    ?>

    I’ve tried following some tutorials but I know almost NO PHP and my functions file has an array that the tutorials do not mention.

    Many Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter theplastickid

    (@theplastickid)

    Bump

    Gerald Yeo

    (@geraldyeo)

    Thread Starter theplastickid

    (@theplastickid)

    I have and I also have followed the tutorials but the structure in those tutorials is different in the Starker theme. Thats why I have posted a snippet of code above.

    Thread Starter theplastickid

    (@theplastickid)

    It seems I have solved my own problem I took the above if statement and repeated it. which generated two sidebars.

    Gerald Yeo

    (@geraldyeo)

    EDIT: didn’t see your last reply…

    Ok. I hope the following will be of help….

    First replace:

    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>',
    	));

    with:

    if ( function_exists('register_sidebar') )
    	register_sidebar(array('name'=>'primary_sidebar',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h2 class="widgettitle">',
    		'after_title' => '</h2>',
    ));

    Following which, declare a second sidebar:

    if ( function_exists('register_sidebar') )
    	register_sidebar(array('name'=>'secondary_sidebar',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h2 class="widgettitle">',
    		'after_title' => '</h2>',
    ));

    In your sidebar.php, replace

    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() : ?>

    with

    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('primary_sidebar') ) : ?>

    To add a second sidebar, add the following code to the desired location:

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

    Thread Starter theplastickid

    (@theplastickid)

    I thought I’d had solved the problem but I hadn’t came back here and saw your response and my problem is now resoloved

    Thank you very much geraldyeo, really appreciate it.

    Dear geraldyeo,

    I stumbled upon the exact same thing. So I was pretty happy to find this post. I’ve tried the above but somehow it’s not working, I get a totally blank page when I replace:

    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>',
    	));

    with

    if ( function_exists('register_sidebar') )
    	register_sidebar(array('name'=>'primary_sidebar',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h2 class="widgettitle">',
    		'after_title' => '</h2>',
    ));

    in my functions.php. And yes, I also did replace:

    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() : ?>

    with

    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('primary_sidebar') ) : ?>

    I’ve tried it with just the primary sidebar as with both primary and secondary, both don’t work. Any help?

    Best, Salli

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add a side bar to template’ is closed to new replies.