Skip to content
Advertisement

WordPress automatically adds and between widgets areas, how to avoid it?

So I have had to edit some code of the template I am using because I need two widget areas in the header, I have managed to achieve it, but the problem comes when WordPress adds <div> and <p> between them and I do not want that because I need them in the same line, not in two lines.

This is what I have done so far:

Inside the file functions.php I have added a new sidebar in the function envo_ecommerce_widgets_init() just after the default sidebar for the header:

JavaScript

Then I have added that new sidebar in the file template-part-topnav.php which contains the whole structure for the header.

JavaScript

The new widget area has been created sucessfully:

But when I add something to both widget areas, this is the result:

bbb is inside the new widget area and aaa is inside the default widget area.

If I inspect the website, this is the result:

As you can see, there are <div> and <p> between both widget areas and that prevents from placing both widget areas in the same line.

Is there a way to avoid this?

This is the template I am using in case you need it. Thank you in advance!

Note: When I say “default widget area” I mean, it is the widget area that came with the template by default.

Edit: The answer of @Manish Negi has fixed the issue but it only works when I add text. However, I want to place a slider and a login form in them and it is adding another space between them again…

I am using two plugins for that, MetaSlider and WordPress Login Form

I add the metaslider shortcode in the first widget area:

I add the WP login form in the second widget area:

And this is the result:

As you can see, it is adding again a space between the slider and the login form and I want them in the same line.

Advertisement

Answer

The WordPress text widget automatically converts text into paragraphs. Some CSS can help to get your result.

Replace your code into template-part-topnav.php file

JavaScript

And add little CSS styling for this section

JavaScript

That’s it.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement