0

Im using Storefront-paper theme for a blog, and for my sorprise, sidebar.php include a code to block possibility to have empty widget area.

In this case I would like to use a page how front page, but I discover how developers never included the css code for this exception, and If you disable widgets, the area appears empty but content page not expand the post to all page producing a strange hole in the right.

sidebar.php is:

if ( ! dynamic_sidebar( 'sidebar-1' ) ) :

And I need to modify the two css structures like

#primary {width:71%;float:left;}
#secondary {width:24%;margin-left:5%;float:left;}

To include the option when widget area is empty pass to be primary 100%. How can I do this? I'm interested in all the blog, and really I can't understand why development not included this option.

1 Answer 1

0

I am not exactly sure what you're question is but I think you are looking for something like this, mostly cribbed from the Codex:

if ( is_active_sidebar( 'sidebar-1' ) ) { ?>
    <ul id="primary"><?php 
        dynamic_sidebar( 'sidebar-1' ); ?>
    </ul><?php 
}

If the sidebar is not in use, no markup will display. You could add an else is you want:

if ( is_active_sidebar( 'sidebar-1' ) ) { ?>
    <ul id="primary"><?php 
        dynamic_sidebar( 'sidebar-1' ); ?>
    </ul><?php 
} else {
    <ul id="secondary"><?php 
        // some other code ?>
    </ul><?php 
}
3
  • Thanks, the problem is how is defined css code. Part of post content is defined how width 71% and secondary 29%. I don't know how to change the value of id primary inside css to adapt correctly the content when sidebar is empty. The problem not seems to be php code. Value width is defined without exception. How can I create this exception inside css?
    – deconya
    Commented Jun 18, 2015 at 17:21
  • You can't "change the value of id primary inside css". CSS doesn't work that way. You have to change the markup as it is generated in PHP, which is what I have showed you have to do. You could alter the markup with Javascript but that would not be a good solution in this case in my opinion.
    – s_ha_dum
    Commented Jun 18, 2015 at 17:35
  • OK, If I can't change primary value in structure, how I can modify the basic css structure? In your explanation you only explains how to introduce the exception php code, but I see how css has no dynamic values, how normally themes adapts the screen when widget area is empty? Seems to be dificult but I understand that half of blogs has pages without widgets.
    – deconya
    Commented Jun 18, 2015 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.