• Hey everyone,

    I recently took on a site which I’ve converted to Joomla to WordPress. One of the issues I’ve noticed however is my client has a series of posts by a number of different authors who it looks like wrote their documents in Microsoft Word and they’ve copied and pasted the entries into their CMS.

    Is their a way to strip existing posts in the wordpress database of their font styling (color, typeface size) etc. and default to the css attributes? I’ve tried a few different ways but they all strip out the actual paragraphs themselves too. Is there a way to just target the styling of the fonts themselves, at the moment I have about 100 posts with nearly all of them in an inconsistent format and don’t really want to ask my client to go through and amend this unless I really have to.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Is there a way to just target the styling of the fonts themselves…

    I don’t think so. Those are probably inside ‘style=”…”‘ attributes, which take precedence over anything you can do in a stylesheet, or in a ‘style’ tag.

    You should be able to delete that ‘style’ attribute using preg_replace and a carefully constructed regex rule.

    Thread Starter masok88

    (@masok88)

    thanks for getting back to me got any ideas on how I would do that? Did a google and didn’t come back with anything.

    I offered a suggestion– preg_replace. Something like:

    $str = preg_replace('/style=[\'"][^\'"]*"/','',$str);

    caveat emptor: That works on my test case, unless I have a typo in the transcription. It is not by any stretch adequately tested. Don’t trust it with important data until you have done some significant dry runs with dummy data. If you know for certain that your style is wrapped ing double quotes you can use " instead of [\'"] and [^\'"]

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Strip Posts of font styling’ is closed to new replies.