Web Design Forum: Wordpress auto formatting - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Wordpress auto formatting Why does it keep putting 'P' tags around everything!? Rate Topic: -----

#1 User is offline   wickywills 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 70
  • Joined: 23-April 11
  • Reputation: 7
  • Gender:Male
  • Location:Southampton
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 18 January 2012 - 01:43 PM

I am just starting to get into Wordpress (I know, late to the game) and am pulling my hair out as to why WP keeps inserting Paragraph tags around everything you put into the HTML editor (even after I have manually gone in and removed them!!).

This seems to be a very common problem, and so far no-one (that I have found) has found a decent solution to it.

I have tried installing various wpautop/tinymce plugins, and so far I have only been able to remove P tags around EVERYTHING - which is obviously not ideal.

I just don't understand why Wordpress can't just output what you insert into the editor - does anyone here have any solutions to this?

Basically, I want to do this (just as an example):

<img src="myimage.jpg"/>
<p>some text</p>


however wordpress does this (note the additional P tags around image):

<p><img src="myimage.jpg"/></p>
<p>some text</p>


Any help much appreciated! :)

thanks
James

This post has been edited by Renaissance-Design: 18 January 2012 - 02:52 PM
Reason for edit: Please use the code button or tags to format your code.

0

#2 User is online   MikeChipshop 

  • Small but imperfectly formed
  • Group: Moderators
  • Posts: 7,046
  • Joined: 19-April 10
  • Reputation: 503
  • Gender:Male
  • Location:Scotland

Posted 18 January 2012 - 02:04 PM

Try this, not used it my self but a client of mine does and he swears by it http://wordpress.org...ugins/raw-html/
0

#3 User is offline   wickywills 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 70
  • Joined: 23-April 11
  • Reputation: 7
  • Gender:Male
  • Location:Southampton
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 18 January 2012 - 02:21 PM

View PostMikeChipshop, on 18 January 2012 - 02:04 PM, said:

Try this, not used it my self but a client of mine does and he swears by it http://wordpress.org...ugins/raw-html/


Thanks for the reply MikeChipShop - I have just tried using the plugin that you posted, and it seems to just add even more paragraph tags around items the moment you toggle between "Visual" and "HTML" mode within the editor.

All I want is for WP to output exactly what I enter in HTML (and for it to retain my HTML after toggling between Visual/HTML) - really can't understand why WP is screwing with my code!!

Even just inserting an image on it's own into a post, WP puts P tags around it!
0

#4 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 18 January 2012 - 02:54 PM

In HTML, images are an inline element. Inline elements cannot sit on their own, they must be contained in a block-level element. I know your WP content may already be contained in a block-level element (a <div> or <section>), but the editor doesn't know this and it isn't its responsibility - it deals with the content itself, so it tries to ensure that your images are wrapped in paragraphs. If you need your image to stand on its own, work with the editor rather than against it. Eg, the following is valid HTML because the inline <img> is contained within the block <p>:

<p><img src="myimage.jpg"/>
some text</p>


Assuming you're separating your paragraphs with a 1.5em bottom margin, simply give your images display: block and the same 1.5em bottom margin.

Alternatively, why not just accept the <p> around the image?

This post has been edited by Renaissance-Design: 18 January 2012 - 02:55 PM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users