Viewing 15 replies - 1 through 15 (of 16 total)
  • Have you read the section in the Codex: Different Sidebars Anyone?

    Thread Starter kevinwiles

    (@kevinwiles)

    Hi,

    So the below in bold would be what i need to change to make new widgets for each sidebar?

    <?php if ( function_exists (‘register_sidebar’)) {
    register_sidebar (‘custom‘);
    } ?>

    Also then How do I define what this side bar uses for the page so it only appears on one page?

    The register_sidebar(‘custom‘) only registers the file you write called sidebar-custom.php. See the sidebar.php file in your theme’s folder for an example.

    I am not exactly sure what you mean by ‘appears on one page’. If you mean a Page (not a Post), then to call your sidebar, you modify the template for the page and change the call from get_sidebar() to get_sidebar(‘custom’).

    If you mean a page of Posts, say the first page, but not the second, third, etc, then you need to put in code to test the page number and call the desired sidebar based on the page number. Something like this:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    if ($paged == 1) {
       get_sidebar(); // Use the default sidebar for page 1
    } else {
       get_sidebar('custom'); // Use the custom sidebar for other pages
    } ?>
    Thread Starter kevinwiles

    (@kevinwiles)

    Hi,

    I have tried all the guide basically on the below page

    http://www.kevinwiles.co.uk/about/top-10-seo-tips/

    I want a unique sidebar on this page only not on any other page, any ideas?

    Thread Starter kevinwiles

    (@kevinwiles)

    Becuase that page is just a normal page isnt it just generated by hte page.php? Which means Id need to do something elsE?

    If this is using page.php, modify it like this.

    In the loop, save the page ID to a variable, $savedID for example. Then, use code like this for the sidebar:

    <?php if ($savedID == 41) {
       get_sidebar('custom'); // Use the custom sidebar for page ID 41
    } else {
       get_sidebar(); // Use the default sidebar for other pages
    } ?>
    Thread Starter kevinwiles

    (@kevinwiles)

    Thanks

    I dont really undertsnad sorry to be a pain,

    As I go into my Page PHP file the only sidebar info I have is

    <div class=”sidebar_pad”>
    <?php
    if (function_exists(‘dynamic_sidebar’) && dynamic_sidebar(‘Sidebar’)):
    endif; ?>
    </div>

    Since page.php is used for all single pages, you should save the ID of the current page while in the loop. Then use code like the following to test the saved ID and display the correct sidebar:

    <div class="sidebar_pad">
    <?php
    if ($savedID == 41) {
       if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar-custom')):
       endif;
    } else {
       if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar')):
       endif;
    }?>
    </div>
    Thread Starter kevinwiles

    (@kevinwiles)

    Hi,

    Where do I get the id from?

    Thread Starter kevinwiles

    (@kevinwiles)

    Hi,

    I found the page ID changed this but it still doesnt work!

    Thread Starter kevinwiles

    (@kevinwiles)

    This is all the code in my sidebar-top10.php

    <?php if (!is_home()){?>
    <!– begin sidebar –>
    <div class=”sidebar_about”>
    dddddd
    <div class=”sidebar_pad”>
    ddddd

    </div>

    <!– end sidebar –>
    <?php }?>

    I would suggest starting with a copy of the standard sidebar.php in your theme and modifying it.

    Thread Starter kevinwiles

    (@kevinwiles)

    Hi,

    My stanadard side bar has nothing in uit!

    Kevin, just to be clear on what you are looking for, are you trying to have a unique widget on one page only, or are you trying to have custom sidebar content that does not come from a widget?

    Thread Starter kevinwiles

    (@kevinwiles)

    Hi,

    Really sorry to be a pain is there any chance you could have a look for me?

    I think the issue is that the page Top 10 SEO tips doesnt know what side bar to call.

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘Sidebars’ is closed to new replies.