• I’m making a WordPress theme, and by default, WordPress pages use a container <div class="wp-site-blocks"> to wrap all block content. However, I want to add a custom container <div class="wrapper"> before all block content. I found a function get_the_block_template_html() in wp-includes and would like to know how to modify it so that my container wraps the content as <div class="wp-site-blocks"><div class="wrapper">...blocks</div></div>.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    That function doesn’t have any filter hooks we can use to accomplish what you want. If you look at the function’s source code, you’ll see it calls a number of functions whose returned value is assigned to $content. There’s a chance one of those might have a filter hook you could use to add your container tags.

    I did a cursory check of a few but didn’t see anything useful. This was not an exhaustive investigation, there could still be an opportunity there somewhere.

    If you can determine what function calls get_the_block_template_html(), it might have a filter hook you could use.

    Depending on why you want this extra container, there might be an alternative approach that would accomplish what you want without adding another container.

Viewing 1 replies (of 1 total)
  • The topic ‘Add a custom global container to the template.’ is closed to new replies.