• Resolved tabascq

    (@tabascq)


    Hi there, I am new to WordPress and I am trying to add a custom <div> to a post. I am using a custom HTML block and trying to add the following (from code editor view):

    <!-- wp:paragraph -->
    <p>bleh</p>
    <!-- /wp:paragraph -->
    
    <!-- wp:html -->
    <div class="foo" foodata="mydata">why</div>
    <!-- /wp:html -->

    and the rendered page ultimately has the following in it:

    <div class="entry-content">
        <p>bleh why</p>
    </div>

    What is likely to be responsible for mangling my custom HTML and how do I make it stop?

    FWIW, I am using the Twenty Twenty-One theme with no changes, and I installed a few plugins that I have since deactivated/uninstalled in the hopes that this would help me understand the problem (it didn’t). My server is running WordPress 5.8.2.

    • This topic was modified 2 years, 12 months ago by tabascq.
    • This topic was modified 2 years, 12 months ago by tabascq. Reason: add WordPress version
    • This topic was modified 2 years, 12 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 3 replies - 1 through 3 (of 3 total)
  • I freshly installed WordPress (Twenty Twenty-One with no plugins) and could not recreate your issue. Here’s my post content from the front-end.

    <p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>
    
    <div class="foo" foodata="mydata">why</div>

    Here’s a similar situation where the problem was resolved by editing the post as a user with more capabilities.
    https://www.ads-software.com/support/topic/tag-removed-from-custom-html-block/

    This could be your solution if you’re running a multisite.

    Note: In WordPress Multisite, only Super Admins have the unfiltered_html capability.

    https://www.ads-software.com/support/article/roles-and-capabilities/#unfiltered_html

    Thread Starter tabascq

    (@tabascq)

    I appreciate the suggestion, but this does not appear to be my issue at first glance. I am editing as an Administrator and I do not think I have Multisite enabled (though, to be honest, I do not know how to tell for certain). Moreover, the HTML I get is different from the “similar situation” link you provided. When I paste the content from that issue:

    <!-- wp:paragraph -->
    <p>before</p>
    <!-- /wp:paragraph -->
    
    <!-- wp:html -->
    <script>document.write('<div>hello world</div>');</script>
    <!-- /wp:html -->
    
    <!-- wp:paragraph -->
    <p>after</p>
    <!-- /wp:paragraph -->

    I get even less:

    <p>before after</p>

    Thread Starter tabascq

    (@tabascq)

    Oho, I think I’ve been tricked by the summary/excerpting feature of a page. My blog page has been getting a summary version of the post content, which is smashing paragraphs together etc. Knowing this, I managed to find the option in Excerpt Settings to turn that off. But thanks for the idea!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom HTML getting mangled’ is closed to new replies.