Forums

Blind developer has question about sidebar widgits (3 posts)

  1. MrTouch
    Member
    Posted 2 years ago #

    Hi,

    Using WP 2.91 and want to create pages on a single site for local geographic areas. I am blind and not sure I completely understand the concept of the sidebar in Wp, but want to know how I can add localized content for each page I create....weather....traffic...local events, etc. with the use of sidebar widgits. I want my visitors to see a more hometown oriented site when they click on their respective pages.

    How do you specify that a particular group of sidebar items goes on a specific page, and not across the entire site.

    Also, does anyone know if there is a plugin or widgit that would allow some other way of moving widgits around other than the drag and drop already in WP? The drag and drop feature is not accessible through my screen reader/access software.

    Thanks for your input on this.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    How do you specify that a particular group of sidebar items goes on a specific page, and not across the entire site.

    You create widget ready areas with different names and place them in different sidebars.

    so, in functions.php you might have:

    if (function_exists('register_sidebar')) {
    	register_sidebar(array(
    		'name'=> 'Sidebar',
    		'id' => 'sidebar',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    	));
    	register_sidebar(array(
    		'name'=> 'Sidebar B',
    		'id' => 'rsidebar-b',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3>',
    		'after_title' => '</h3>'
    	));
    }

    You could then create two sidebar files: sidebar.php and sidebar-b.php:

    SIDEBAR.PHP

    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar')) : ?>
    [ default content if widget not used ]
    <?php endif; ?>

    SIDEBAR-A.PHP

    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar B')) : ?>
    [ default content if widget not used ]
    <?php endif; ?>

    Finally, you can call the appropriate sidebar using conditionals in your templates. so page.php may use the code:

    <?php if is_page('Kansas') get_sidebar('b');
    else get_sidebar();?>

    In this way, sidebar B will be called on the Kansas page and will only show widgets loaded into that sidebar via Admin/Appearance/Widgets.

    Hope that helps.

  3. MrTouch
    Member
    Posted 2 years ago #

    That is exactly what I was looking for! Thanks so much for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags