0

I am trying to add a widget for for some reason I cant wrap an element around the widget.

Here's the html in the index.php:

<article class="intro-widget">
                <p>
                    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Intro')) : ?>
                        <!--<p>No introduction added.</p>-->
                    <?php endif; ?>
                </p>
            </article>

And here's function.php code:

if (function_exists('register_sidebar')) {
    register_sidebar(array(
        'name'=> 'Footer',
        'id' => 'footer',
        'before_widget' => '<div class="footer-widget">',
        'after_widget' => '</div>',
        'before_title' => '<h5>',
        'after_title' => '</h5>',
    ));
    register_sidebar(array(
        'name'=> 'Intro',
        'id' => 'intro',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<h5>',
        'after_title' => '</h5>',
    ));
}

First sidebar wraps the div as expected the second opens and closes the <p> (with some whitespace) before contents of the widget. Issue is the same if I add the p tag in the before_widget/after_widget properties.

Here's the output:

<article class="intro-widget">
            <p>
                              </p>
                <h5>test</h5>           <div class="textwidget">Studio phi is all about architecture, design aesthetics and helping people to put their great ideas on paper and eventually on the ground or maybe even on the water... as far as our imaginations go.</div>
                    <p></p>
        </article>

What is my mistake?

Edit: It seems that div wraps as expected but p won't, no idea why this would make a difference.

  • What do you want the output to be? As far as I can tell, it is working as it should be. Although, you cannot place <h5> or <div> elements inside a <p> element. – Seamus Leahy Dec 7 '13 at 3:31
  • My mistake, output edited. – DominicM Dec 7 '13 at 14:22
  • Are you getting the output from the source view or from Firebug/Web Inspector? I ask because Web Inspector will "correct" the HTML. In this case, it could be closing and opening the <p> elements as <h5> and <div> elements are not allowed inside a <p>. – Seamus Leahy Dec 7 '13 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.