Disable smart quotes in WordPress without requiring www prefix

If you've attempted to visit this site without using the "deprecated" www prefix since the beginning of the year, you probably noticed that it wasn't coming up. I hope you noticed, because I didn't until this morning.

On December 31, I got tired of WordPress messing with my source code and changing all of the quotes. So I found instructions from Peter Cooper on disabling that feature. I took his advice and added the line "<?php remove_filter('the_content', 'wptexturize'); ?>" to the bottom of functions.php. A quick test showed that it worked. Hurray! I can copy and paste source code!

Fast forward to today, when I tried typed in http://adventuresinsoftware.com/blog and got a blank page. http://www.adventuresinsoftware.com/blog worked, as did http://adventuresinsoftware.com (the www. and /blog get added via redirect). So I go through my 5-step process: panic, research, try to fix, fail, and call for technical support. The folks at eApps pointed me in the right direction. They found this error message (which I had seen and disregarded, to my peril):

PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wordpress/wp-content/themes/ais2/functions.php:399) in /var/www/html/wordpress/wp-includes/pluggable.php on line 390

The problem is that Word Press is trying to perform a redirect to put the www back into the URL. In doing so, it ran up against the output that functions.php had already performed. The first output causes the HTTP header to be written, making it impossible to perform the redirect.

Here's my solution
Before doing anything else, I deleted the line that I had added to functions.php and tried the site again. It was back to its no-www-necessary behavior. But the troublesome "smart" quotes were back.

So the challenge was to find a way to remove the wptexturize filter without bringing down the site. I dusted off grep and took a tour through the code. I found the places in default-filters.php where that filter was being added. So instead of removing it, I just deleted those add_filter lines.

And so now, thanks to the help of Peter Cooper and eApps, I have copyable code and no www necessary. Now if I could only get Word Press to stop putting the www back into the URL for me.

Update
I found two places in the site options where I had www in front of the domain name. I fixed those, and now it redirects you away from www instead of toward it. So even that is fixed.

Leave a Reply

You must be logged in to post a comment.