Using WordPress version 3.2.1

I've noticed that when I use this filter:

add_action('the_content', 'myFunction', 0);

The content editor places the content written from "myFunction" within the last paragraph tag of the content. How can I force the WP to append the code after the last tag?

For example, if my content is...

<p>This is a paragraph</p>

And the "myFunction" routine appends "And this is some extra text" to the_content, the end result in the browser becomes:

<p>This is a paragraphAnd this is some extra text</p>

Although I want it to be:

<p>This is a paragraph</p>And this is some extra text

1 Answer 1


Your filter is being applied before wpautop, the filter which wraps all of the paragraphs in WordPress content with <p> tags.

A value of zero for priority means that your filter will be applied first, before all other formatting filters. Try applying your filter later - with a priority higher than 10, the default, which is where wpautop is applied.

So, add your function like this:

add_filter( 'the_content', 'myFunction', 11 );
  • +1 Sounds like a perfect solution (and explanation). Thanks!
    – N2Mystic
    Aug 24, 2011 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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