WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Dynamic Sidebars? (2 posts)

  1. Amber
    Member
    Posted 3 years ago #

    So what I'm trying to do is include custom dynamic sidebars for specific pages using only the sidebar.php file

    Currently I have a page called "page-coupon.php" and I'm calling my sidebar as follows:

    <?php if(is_page()) {
    //We're on a "page", which?
    if (is_page('279')) {
    // Ah, the Coupons page!
    get_sidebar();
    } else {
    // If we're not on the coupon pages
    if(!get_post_meta($post->ID, "noSidebar", true)) {
    get_sidebar();
    }
    }
    };
    ?>

    in my functions.php i have the following to activate my widgets:

    //Activate Your Widgetized Areas
    if ( function_exists('register_sidebar' ) ) {
    $allWidgetizedAreas = array("Sidebar", "couponSidebar", "Footer1", "Footer2", "Footer3");
    foreach ($allWidgetizedAreas as $WidgetAreaName) {
    register_sidebar(array(
    'name'=> $WidgetAreaName,
    'before_widget' => '<div id="%1$s" class="widget %2$s left half">',
    'after_widget' => '</div>',
    'before_title' => '<h3 class="widgettitle">',
    'after_title' => '</h3>',
    ));
    }
    }

    and I'm trying to figure out the best way to add this to my sidebar.php file. to start with I have:

    <ul>
    <?php if (is_page('279')) {
    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('couponSidebar') ) : ?>
    <?php } endif; ?>
    
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar() ) ?>

    I don't think the above is correct and I'm not 100% sure how to go about getting it to work. Currently my widget areas generate and I can place stuff into them but all the sidebars appear blank. I've reviewed lots of articles on custom sidebars but haven't been able to find an answer. Can anyone offer up any assistance?

  2. Amber
    Member
    Posted 3 years ago #

    Anyone have any thoughts on this?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.