I'm trying to purge my WordPress content from "false" carriage return (CR). These are caused after a migration of my content, that now presents from time to time a   code that makes the web rendering engine to "paint" a CR where I would like to be nothing. The paragraphs seem to have a double CR because of this, and look too far apart.

I'd like to be able to make a MySQL query in order to get rid of that strings, but at the moment I haven't found the key. What I've tried is

UPDATE wp_posts set post_content = replace (post_content,' ',' ');

But i get

<p> </p>

where before were the &nbsp; strings. This seems not the answer at all. Could it have to be with the ampersand, and in that case, should I use something like &amp;nbsp; or something similar?

link|improve this question

77% accept rate
Of the 16 questions you have asked you have only accepted 2 answers. Help the community out by upvoting and accepting the answers that have helped you. FAQ – hobodave Mar 13 '11 at 2:47
Even if they are not definitive solutions? I thought only those answers that solved problems had to be accepted... – javipas Mar 14 '11 at 23:17
That is correct. Thanks for acknowledging my comment. It shows that you're not just being lazy :). If you solved the problem yourself, you can always answer your own question and accept that answer. You won't get the reputation for the Accept, but at least you will get your accept rate up, and be helpful to future readers. – hobodave Mar 14 '11 at 23:20
Thanks for the explanation, hobodave. I'm affraid I didn't solve the problem, but if I do be sure I will publish here my own answer. Meanwhile, I keep on trying! – javipas Mar 23 '11 at 14:14
feedback

2 Answers

up vote 0 down vote accepted

I am not sure why &nbsp; would be interpreted as a carriage return, because it should look like a space (Non-Breaking SPace). In any case, I was able to get your SQL to work on a test database I created by changing the string to have double-quotes.

UPDATE wp_posts set post_content = replace (post_content,"&nbsp;","");

Also note, there is no space between the last pair. You want it to replace &nbsp; with nothing, not a space.

link|improve this answer
Thanks for the idea, but din't work :( The double quotes didn't change the DB, although you're right: I want to replace that with nothing. When I try your idea, I get this: mysql> UPDATE wp_posts set post_content = replace (post_content,"&nbsp;",""); Query OK, 7 rows affected (1.34 sec) Rows matched: 15232 Changed: 7 Warnings: 0 – javipas Mar 13 '11 at 15:58
feedback

The code <p>&nbsp;</p> is frequently used by some GUI HTML editors to represent a carriage return. I would be that what you really need to be searching for and removing is <p>&nbsp;</p>, and not just &nbsp; which is just a non-breaking space character.

link|improve this answer
Unfortunately, no changes either with that idea. But it should have made a difference: mysql> UPDATE wp_posts set post_content = replace (post_content,"<p>&nbsp;</p>",""); Query OK, 0 rows affected (1.26 sec) Rows matched: 15232 Changed: 0 Warnings: 0 – javipas Mar 13 '11 at 16:00
Aaah...I wasn't thinking about the nbsp wrapped in the <P> tags for a CR. That makes sense. – Alex Mar 13 '11 at 16:48
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.