• Hi

    I have asked this before I know, but I still haven’t got it working and there are no other resources that I can find for WP.

    Ok I have a client who has slight variations on the sidebar requirements for everyone of the 8 pages of the site.

    I have put the following in function.php:

    <?php
    if ( function_exists(‘register_sidebars’) );

    register_sidebar(array(‘name’=>’sidebar’,));
    register_sidebar(array(‘name’=>’sidebar_demolition’,));
    register_sidebar(array(‘name’=>’sidebar_siteregen’,));
    register_sidebar(array(‘name’=>’sidebar_currentuk’,));
    register_sidebar(array(‘name’=>’sidebar_asbestos’,));
    register_sidebar(array(‘name’=>’sidebar_planthire’,));
    register_sidebar(array(‘name’=>’sidebar_accreditation’,));
    register_sidebar(array(‘name’=>’sidebar_specialist’,));
    register_sidebar(array(‘name’=>’sidebar_contact’,));

    ?>

    And I get the drop in the sidebar widget area, which is nice.

    however how do I connect the pages to the individual pages ?

    I have tried <?php get_sidebar(2); ?> but this doesn’t do it.

    So would something like <?php get_sidebar(‘demolition’); ?> work ? or is that too simple?

    Really need some guidance on this one.

    It would be great if someone actually took the time to point me in the right direction.

    Thanks

    C

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter acknowledged74

    (@acknowledged74)

    Ok I’ve tried <?php get_sidebar(‘demolition’); ?> the main sidebar just overides it.

    Thread Starter acknowledged74

    (@acknowledged74)

    First of all you have to have a seperate template for each page, which changes the sidebar.

    Also you can’t do <?php get_sidebar(2); ?> as this only works when you use a dynamic sidebar with numbers.

    So your second line should work. Each sidebar has to be called by using the name you’ve given it.

    <?php get_sidebar(‘sidebar_demolition’); ?>

    You can’t use <?php get_sidebar(‘demolition’); ?> as you have called it sidebar_demolition – so use the one above ??

    Thread Starter acknowledged74

    (@acknowledged74)

    mmmm

    I’ve tried <?php get_sidebar(‘sidebar_demolition’); ?> which of course makes perfect sense thanks, but it is still just showing the main sidebar ?

    Thread Starter acknowledged74

    (@acknowledged74)

    So what I have is:

    https://acknowledgedwebtest.info/maldondemo/wp-content/themes/corporate-globe/sidebar_demolition.gif

    added a search widget just to make the difference clearer.

    demolition.php now reads:

    <?php
    /*
    Template Name: Demolition And Dismantling
    */
    ?>

    <?php get_header(); ?>
    <?php get_sidebar(‘sidebar_demolition’); ?>

    You cant call it like that. Sorry that was my mistake ??

    You have to call it like this ??

    <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(‘sidebar_demolition’) ) : else : ?>
    <?php endif; ?>

    Thread Starter acknowledged74

    (@acknowledged74)

    Are you need to offer it the option of a the dynamic sidebar, thats make a bit more sense, cool I’ll have a look.

    Thanks for taking the time Madsk.

    No problem ?? I hope you get it working.

    Thread Starter acknowledged74

    (@acknowledged74)

    Hi

    Once the ‘pages’ widget has been chosen it is then unavailable for further sidebars ?

    Maybe I’m missing something ?

    The navigation in the sidebar needs to be the same for every page, and updated if pages are added or removed.

    Thread Starter acknowledged74

    (@acknowledged74)

    Actually I pressume that I need to add more to the function.php and therefore to the php in the innitial post (top of this page) ?

    Thread Starter acknowledged74

    (@acknowledged74)

    Another problem is that the new sidebars I have added don’t have style attached.

    Any ideas how to do this, actually this would also be an alternative meathod if you can’t reuse the widgets.!?!!?

    Any help would um really help !!

    Conrad

    Well i can show you my functions.php – i’m only using numbers as i find it easier. If you want it to be a little better organised you could just comment what each sidebar belongs too.

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebars(4);
    ?>

    Change the 4 to the number of sidebars you are going to use. Then you can call them with the code above:

    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(3) ) : else : ?>
    <?php endif; ?>

    Again change the number to the one you want to use.

    About the style – wrap the above code within an ul

    <ul id=”sidebarwhatever”>
    code above
    < /ul>
    Now style the sidebar (ul#sidebarwhatever) and each sidebar will use this style so they will look the same. I hope this helps ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to display different sidebars on each page ?’ is closed to new replies.