WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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
share|improve this question
up vote 3 down vote accepted

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 );
share|improve this answer
+1 Sounds like a perfect solution (and explanation). Thanks! – N2Mystic Aug 24 '11 at 12: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.