Jump to content

Archived

This topic is now archived and is closed to further replies.

Umar Adil

WordPress adding br and p tags

Recommended Posts

Umar Adil

Sometimes I find stray p or br tags appearing inside a block of content that  and this can mess up the layout by adding extra spacing where I don’t want it. How can I fix this?

 

Whenever I am posting some content in WordPress post page it is showing some paragraph tags like<p> and <br/>. Which is showing some extra space in output. So is there any solution for it? How to remove all the tags?

 

 

I found the soln for this on stackoverflow. http://stackoverflow.com/questions/6625458/removing-p-and-br-tags-in-wordpress-posts

 

This happen because of WordPress's wpautop. Simply add below line of code in your theme's functions.php file

remove_filter( 'the_content', 'wpautop' );

remove_filter( 'the_excerpt', 'wpautop' );

For more information: http://codex.wordpress.org/Function_Reference/wpautop

 

How can I change the DMS2 functions.php?


--

Regards,

Umar Adil

Share this post


Link to post
Share on other sites
sheilahoff

Interesting. This relates to my issue which I will post in a unique thread. I know one work-around for this issue is to add the PL shortcode as explained in the docs:;

 

Wordpress is designed to add <p></p> tags whenever you add a new line. This is great when using normal text, but when writing code or using shortcodes, it can be the cause of all sorts of issues.

To resolve this issue, we have created a utility shortcode that stops Wordpress adding <p></p> tags whenever a new linebreak has been used, or in cleaning up copied code to which paragraph tags were included. Simply wrap the [pl_raw][/pl_raw] around your code/shortcode and erroneous tags will be eradicated.

 

But if one is using a child theme I would think you could add the two lines you cited in the functions.php and have it handled. I might check that out. THANKS!


Sheila Hoffman | Hoffman Graphics | Seattle

Share this post


Link to post
Share on other sites
Danny

Hi,

 

Where are you finding these stray <p> or <br /> tags ? 

 

Also, if you want to use that code you will you need to use a child theme, you can use the one I created here if you like, then add the code to the child themes functions.php file.

 

https://github.com/Dannyholt/Skeleton

 

Also, all that wpautop does is changes double line-breaks in the text into HTML paragraphs (<p>...</p>). So if you're experiencing extra line breaks, then you will want to remove a line in your HTML, the same applies to textboxes. This is a WordPress function and not a DMS one.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Umar Adil

I am not using a sub theme,  wrapping the [pl_raw][/pl_raw] around content works for me.


--

Regards,

Umar Adil

Share this post


Link to post
Share on other sites
Danny

The [pl_raw] shortcode has been designed to prevent this. However, it only works once per page and only in the Content area of a WordPress page or post. It will not work in sections such as TextBox or MediaBox.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Umar Adil

Hi @sheilahoff 

 

Thanks for your reply. How do I add the tag in short codes?

 

Example: 

 

[pl_raw]
<div class="container all-border">
<div class="row">
<div class="span6">
<!-- Plan and Pricing for Students -->
[post-content id=3463]
</div>
 
<div class="span6">
<!-- Plan and Pricing for Tutors -->
[post-content id=3465]
</div>
</div>
[/pl_raw]
 
In above example, the extra <p> tags are in included content, I tried to add the wrapper there in included content page also, but it stops working.
 
Thanks

--

Regards,

Umar Adil

Share this post


Link to post
Share on other sites
Danny

What do you mean, I am not entirely sure what you issue is ?


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
GetMeWebDesign

screenshot of the problem? I am presuming that the content looks fine in those posts and they too are wrapped in span 6 


Chrome Developer tools - please use them. If you are not sure how, then it is easy to learn

Be inventive in your keyword search of the forum ie Navi > Navbar > menu > tabs > font > color. Your answer lies there somewhere!

Share this post


Link to post
Share on other sites

  • Similar Content

    • outtareach
      By outtareach
      I have a text box with 0px 0px in the css settings and yet in chrome it is still not aligned on the top flush with the image on the left.  It looks better in firefox but still I need it to look correct in both. this was never an issue before but now it seems to be happening in the update. Seems to be the space for the title which I do not have and I need to remove the space.
       

    • bartok
      By bartok+
      Can someone take a look at the following page of my site: http://test.canalclubvenice.com/menu/
       
      Extra white space is being added on the right hand side of the browser. You are able to scroll left and right.
       
      How do I fix this so that the website fits into the entire space of the browser and there is no white space on either the left or ride side?
×