WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add a PHP str_replace to the add_filter('the_content') function. I believe my problem is that the shortcodes are loading after the str_replace is called.

I have a shortcode that outputs a form, i want to make it that in all HTML form tags, the attribute autocomplete='off'.

Heres the code i have.

add_filter('the_content', 'disable_autocomplete');
function disable_autocomplete( $content )
    return str_replace('<form', '<form autocomplete="off"', $content);

Any ideas?

share|improve this question
up vote 2 down vote accepted

You can change the priority of actions and filters, it's the third argument of add_filter (and add_action) and it defaults to 10. So change it to a high number and have your filter fire way after the shortcodes and other stuff are inserted.

add_filter('the_content', 'disable_autocomplete', 99);
function disable_autocomplete( $content )
    return str_replace('<form', '<form autocomplete="off"', $content);
share|improve this answer
Ahh! So annoying! I put 30 there and it didn't help. Next time ill go higher ;) thanks! – cnotethegr8 Sep 19 '11 at 17:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.