Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

h2 tag is inserting p tag inside html , how to prevent that?

  • BrunoVincent.net

    For some reason, I have a block with an h1 on top and then an h2 under it, but the h2 nests the content into a P tag…

    Here is the code:

    <div class="gb-element-bb0ec8ff">
    <h1 class="gb-text gb-text-2a97ccf1 XL-H1">Youtube Videos</h1>
    
    <h2 class="gb-text" id="XL-H2"><p>This is the youtube videos description</p>
    </h2>
    </div>
  • Hi there,

    Is the h2 dynamically pulled? Can you let me know how did you set up the dynamic tag for the h2? What dynamic data are you trying to pull?

    Let me know 🙂

  • BrunoVincent.net

    It’s dynamic data yes, here is the code:

    <div class="gb-element-6524c67d header-colors">
    <div class="gb-element-bb0ec8ff">
    <h1 class="gb-text gb-text-2a97ccf1 XL-H1">Fast Cars</h1>
    
    <h2 class="gb-text" id="XL-H2"<p><This is the fast cars category</p>
    </h2>
    </div>
    </div>
  • Hi there,

    What is the field type of the ACF field from which you are pulling that dynamic data?

  • BrunoVincent.net

    It’s not a custom field, it’s a taxonomy description dynamic field:

    {{archive_description}}

  • It looks like a bug — by default, the value returned by the function includes the <p> tag.

    For now, you can use this filter to fix it:

    add_filter('get_the_archive_description', function($description) {
        $description = str_replace(array('<p>', '</p>'), '', $description);
        return $description;
    });

    Adding PHP: https://docs.generatepress.com/article/adding-php/

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.