• I have this issue with the order of P and Divs when I add an image. It seems to be mucking up the design. This is what some typical HTML looks like:

    <p>
    <div id="attachment_2045" class="wp-caption aligncenter" style="width: 500px"><img class="size-full wp-image-2045" title="new-sprite-google" src="http://www.malcolmcoles.co.uk/blog/wp-content/uploads/2009/04/new-sprite-google.png" alt="New google sprite (left); old google sprite (right)" width="490" height="191" />
    <p class="wp-caption-text">New google sprite (left); old google sprite (right)</p>
    </div>
    </p>

    (from http://www.malcolmcoles.co.uk/blog/new-google-sprite-july-2009/)
    I thought divs weren’t allowed in <p>s?

    It’s gone even odder on other pages:

    <p>
    <div id="attachment_1943" class="wp-caption aligncenter" style="width: 502px"><img class="size-full wp-image-1943" title="bbc-ashes-2005" src="http://malcolmcoles.co.uk/blog/wp-content/uploads/2009/04/bbc-ashes-2005.png" alt="Query deserves 4 years ago?" width="492" height="203" /><p class="wp-caption-text">Query deserves 4 years ago?
    </p>
    </div>
    <br />
    Update: It's taking it from the DMOZ entry according to the comment below. Odd behaviour ...
    <div class="tweetmeme_button" style="float: right; margin-left: 10px;">

    That one has got a whole chunk of text not in a <p> … The bit beginning Update.

    Anyone got any clues on what causes this?

Viewing 15 replies - 1 through 15 (of 21 total)
  • I thought divs weren’t allowed in <p>s?

    They’re not.

    Anyone got any clues on what causes this?

    Some custom code or function in single.php by the looks of it.

    Thread Starter malcolmcoles

    (@malcolmcoles)

    I’ve had a hunt round and I can’t see anything obvious. Got any clue what I should be looking for? Is it likely to be some image related thing in the functions file, for instance?

    Yes – I’d check through functions.php

    This is new featured of WordPress 2.6 and newer, to disable the <DIV is simple, just don’t put any text on Edit Image Caption field
    Screen Shot
    Best Regards

    Jauhari

    This is new featured of WordPress 2.6 and newer

    Sorry? I’m currently running 2 separate WP 2.8.2 dev installs and neither shows this invalid nesting with captioned images. I’ve also checked on a client’s 2.7.1 install. The code is valid there too.

    It’s not a feature of 2.6x at all (see wp-includes/media.php). It could be an issue with some themes that have re-written the caption shortcode via the functions.php file but that has nothing to do with WP itself.

    Thread Starter malcolmcoles

    (@malcolmcoles)

    I’d quite like to keep the captions! And I’ve seen other installs, as esmi says, without the invalid nesting. I’ve hunted through functions.php, and can’t see any reference to captions in there.

    I added:
    remove_filter(‘the_content’, ‘wptexturize’);
    remove_filter(‘comment_text’, ‘wptexturize’);
    But I can’t see why this would cause it?

    Thread Starter malcolmcoles

    (@malcolmcoles)

    Also, I’ve just put an image in and nothing else and previewed. I get this:

    <p>
    <div id="attachment_2045" class="wp-caption aligncenter" style="width: 500px">
    <img src="xxxx.png" alt="xxxx" title="xxx" width="490" height="191" class="size-full wp-image-2045" />
    <p class="wp-caption-text">xxx</p>
    </div>

    I don’t think it’s the caption causing the problem – the caption <p>s are within the div.
    But a rogue <p> has appeared before the div – with no closing p

    Thread Starter malcolmcoles

    (@malcolmcoles)

    OK, is it related to wpautop?

    This sounds like a similar problem: http://wordpress.org/support/topic/280790

    Thread Starter malcolmcoles

    (@malcolmcoles)

    OK, I’m now talking to myself a lot. But here is another example, which someone solved by disabling a plugin that I don’t use:
    http://wordpress.org/support/topic/189740?replies=11

    So, I think we can conclude that it isn’t the theme or wordpress core, but possibly a plugin. Er, I don’t have any obvious plugins that would cause this. Sigh.

    Have you tried switching to the default theme? I’m 99% sure it’s theme-related.

    Thread Starter malcolmcoles

    (@malcolmcoles)

    Hi, esmi. That was a good idea … but the problem remains – the code stays as it was (with the divs inside the <p>s)

    Do you have any plugins installed? Even inactive ones?

    Thread Starter malcolmcoles

    (@malcolmcoles)

    You’re going to suggest turning them all off aren’t you …

    I have these active:
    Akismet
    AYB Javascript In Posts
    DoFollow
    Get Recent Comments
    Redirection
    ShareThis
    Subscribe To Comments
    TweetMeme Button
    Twitter Tools

    And these inactive:
    Hello Dolly
    WP Automatic Upgrade
    WP Database backup

    Yep. 🙂

    And if that doesn’t work, the next steps are to rename the plugins folder via FTP, then use PhpMyAdmin to reset the plugin folder name in the database to confirm that there’s absolutely no plugin involvement.

    Thread Starter malcolmcoles

    (@malcolmcoles)

    So, I never did solve this. Esmi – I don’t really want to poke about in my database with phpmyadmin if I can avoid it. Are there any other possibilities you can think of? I’ve tried no plugins and the default theme. But the problem persists as you can see in my latest post:
    http://www.malcolmcoles.co.uk/blog/im-a-celebrity-2009-itv-seo
    The code in there looks like this:

    <p><div id="attachment_3457" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-3457" title="im-a-celebrity-2009-gmooh" src="removed" alt="I'm a Celebrity 2009 results" width="300" height="275" /><p class="wp-caption-text">I'm a Celebrity 2009 results</p></div></p>

    (I took the src out to shorten the code!)

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Order of P and Div’ is closed to new replies.