Site logo

Archived topic

footer 1 widget adding paragraphs around content.

3 replies · Started by Josh on February 7, 2022

Viewing posts 1–4 of 4

I'm trying to add content to my footer. The content is going to be a short code. My short code is working fine. However when I add it to the footer 1 widget it surrounds it in paragraph tags. I thought at first it was my short code but I tested my entering a fake shortcode (random text). So in appearance widget I added a shortcode block to my footer 1 widget area. Then I entered shortcode : [dfg-bfds]

<div id="footer-widgets" class="site footer-widgets">
	<div class="footer-widgets-container grid-container">
		<div class="inside-footer-widgets">
			<div class="footer-widget-1">
				<aside id="block-7" class="widget inner-padding widget_block">
					<p>[dfg-bfds]</p>
				</aside>	
			</div>
		</div>
	</div>
</div>

Is there any way to stop this from happening? It is adding extra spacing around my actual shortcode return values

Hi Josh,

The p tag added on your shortcodes is coming from WordPress’ wpautop and there is no WordPress filter for footer widgets which we can utilize to remove this p tag.

As an alternative, can you try adding the shortcode through a Custom HTML block and see if this works?

See this for reference: https://share.getcloudapp.com/DOumJ2Ex

Kindly let us know if this works. Hope to hear from you soon! :)

UPDATE...
Actually it doesn't work. Even in custom HTML blocks after hitting update and then revisiting the widgets page WordPress adds the paragraphs. That's frustrating!

That worked. Thank you Fernando!

Hi Josh,

Can you try adding this PHP snippet?:

add_action( 'after_setup_theme', function(){
     add_filter('widget_block_content', 'shortcode_unautop');
},99);

Here is a link you may refer to with regards to adding PHP: https://docs.generatepress.com/article/adding-php/

Kindly let us know how it goes. :)

This archived topic is closed to new replies.