Take the 2-minute tour ×

In my content I'm giving my <h3> tags id's for the sake of direct linking.

This is how it looks in the post editor:

<h3 id="h3-title">H3 Title</h3>

So that I can directly link to it like this:

<a href="http://example.com/page#h3-title">H3 Title</a>

However, the double quotes are getting escaped somehow, with the html output on the post page looking like this:

<h3 id="\"h3-title"\">H3 Title</h3>

This makes the links not work :(

I've tried numerous things, such as removing the wptexturize filter from the_content, making sure that magic_quotes were off, and even remove_filter('content_save_pre', 'wp_filter_post_kses'); which breaks things magnificently.

I'm seriously considering just creating a filter to remove the slashes, but it seems that they shouldn't have been added to begin with. They're not added to images with id's, for example, so they must be added somewhere. This happens in both visual and html modes.

Any help would be greatly appreciated.

share|improve this question
add comment

5 Answers

up vote 1 down vote accepted

I've noticed that if you uncheck the "prevent linking in heading tags (h1,h2,h3,h4,h5,h6)." in the settings of the SEO Smart Links plugin, the back slashes are removed. I've posted this on the plugin author's page to hopefully be fixed.

share|improve this answer
That's exactly what I ended up doing. Not an ideal solution though :( –  Dan Gayle May 31 '10 at 23:04
add comment

Regarding to the SEO Smart links plugin, this is what worked for me:

I commented out $text = stripslashes($text); in the following code:

if ($options['excludeheading'] == "on") {
    //Here insert special characters
    $text = preg_replace('%(<h.*?>)(.*?)(</h.*?>)%sie', "'\\1'.removespecialchars('\\2').'\\3'", $text);
    // $text = stripslashes($text);
share|improve this answer
This worked perfectly for me! Not sure about any side-effects though. –  gbmhunter Feb 1 at 21:23
add comment

For anyone that comes across this, the SEO Smart Links plugin can be fixed by modifying the SEOLinks_the_content_filter function.


$result=$this->SEOLinks_process_text($text, 0);


$text = stripslashes($text);
$result = stripslashes($result);

I'm no php expert, no idea if this is the optimal fix, but it worked for me. This was a modified fix found on http://www.prelovac.com/vladimir/forum/plugins/seo-smart-links-fix-for-you-seo-smart-links-plugin

share|improve this answer
add comment

You've probably fixed this already, but for those searching google for the answer to remove double escaped quotes in php, make sure the text is first filtered through stripslashes($data) function first.

share|improve this answer
add comment

I'm thinking this may be a plugin interaction. I just created a simple test post on my WP website, and it did not escape the quotes. This is was on WordPress 2.9.1.

share|improve this answer
I should have thought of this solution first, but it appears that you are correct. I audited my plugins, and the SEO Smart Links plugin was the culprit. I'll notify the plugin author. Thanks for the reminder! –  Dan Gayle Jan 15 '10 at 17:05
add comment

Your Answer


