Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 2 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
add comment

Your Answer

 
discard

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.