Disable Auto Format in wordpress

This is a great trick I found today while working on a problem for a client.

What was happening is that wordpress was wrapping her image in paragraph tags and causing it not to float right with text wrapping around it.

The solution was to add this to the functions.php file. (note, make sure you back up your funtions.php file first!)

function my_formatter($content) {
$new_content = '';
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
$new_content .= wptexturize(wpautop($piece));
}
}

return $new_content;
}

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');

add_filter('the_content', 'my_formatter', 99);

Now you simply add [raw] and [/raw] tags around the element you are having a problem with.

Source

What do I need to provide for my website design?

By Dave Fogel | September 3, 2020

We typically ask you for a few examples of websites you like so we can create a mock-up for you to review. You will also need to provide us with the content for the website; in other words, what goes on the pages. This has proven in the past to be the longest hold up…

How long does it take to build a website?

By Dave Fogel | September 3, 2020

For a relatively small website – 10 pages or less, we can usually have your website completed in about a month. Larger websites may take longer, and we will quote as best we can when we see your project.

Do you outsource to India or other countries?

By Dave Fogel | September 3, 2020

Absolutely, 100% No! You can be sure everything about your website will be done here in the USA. The reason for that is simple; we care about the quality of our work and the satisfaction of our customers. Truth be told, we can make a lot more money changing US prices and outsourcing, but the…

Posted in

Dave Fogel

Leave a Comment