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

Signed up For ClickTale

By Dave Fogel | January 12, 2011

We are always looking for better ways to get data from the web. Clicktale is a pretty cool product that allows you to generate heatmaps of you site and find out what people are doing. There is a free trial. Check it out. www.clicktale.com

Adding WordPress 3.0 Menu support to your older site

By Dave Fogel | January 12, 2011

I have come across this a few times when updating older sites to WordPress 3.0 that the fancy new menu system in WP3.0 doesn’t work. Fortunately, this is an easy fix. First off, you will be editing your functions.php file, so make a backup! Now, add this code to your funtions.php file: add_action( ‘init’, ‘register_my_menus’…

Having Multiple Footers in wordpress

By Dave Fogel | January 11, 2011

Sometimes I like to have multiple footers for a site, or at least one for the homepage and one for the rest of the site. Fortunetly, wordpress makes this really easy to do. WordPress has a special template tag for including them into your theme: This function will accept only one parameter, a string, which…

Posted in

Dave Fogel

Leave a Comment