WordPress.org

Ready to get started?Download WordPress

Forums

collapse empty widget areas (WP3)? (5 posts)

  1. transformer617
    Member
    Posted 3 years ago #

    I added three widget areas in the footer of my Thesis theme. When they're empty, I'd like them to just collapse instead of presenting me with three empty (but pretty) boxes.

    I read a 2-year-old solution posted in this forum but it doesn't seem to work with 3.0. Has anyone come across -- or have a solution for this?
    Thanks very much
    Bill

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    check the code of sidebar-footer.php of the Twenty Ten theme.

  3. transformer617
    Member
    Posted 3 years ago #

    Oh, this is very cool! :) Thanks lots for the tip. I modified this piece of code found in the twentyten file sidebar-footer.php:

    if (   ! is_active_sidebar( 'first-footer-widget-area'  )
    		&& ! is_active_sidebar( 'second-footer-widget-area' )
    		&& ! is_active_sidebar( 'third-footer-widget-area'  )
    		&& ! is_active_sidebar( 'fourth-footer-widget-area' )
    	)
    		return;

    Worked like a charm. My next step in making this even more awesome would be if, for instance, only one or two widgets were present in a three widget block, the dimensions would adjust to fill the area. Any ideas about that? (Maybe I should post this question separately)

  4. crazycharlie
    Member
    Posted 3 years ago #

    Along the lines of this post, I'm trying to hide the left-hand column in header.php in a PHP conditional when the sidebars are not active. However, the following is returning false.

    <?php if (is_active_sidebar('sidebar1') && is_active_sidebar('sidebar2')) { ?>
       <div id="left-col">
          <?php get_sidebar(); ?>
       </div>
       <div id="right-col">
    <?php } else { ?>
       <div id="right-col-wide">
    <?php } ?>

    Any thoughts on why this wouldn't work?

  5. crazycharlie
    Member
    Posted 3 years ago #

    I figured out the problem. My function had an extra attribute for id that it didn't recognize.

Topic Closed

This topic has been closed to new replies.

About this Topic