I'm writing a plugin that adds some extra thumbnails, checkboxes, etc to the end of a post.

I'm trying to figure out how to use add_filter properly.

Basically, I've got

add_filter('the_content', 'do_some_magic_at_the_end');

And there is a corresponding do_some_magic_at_the_end function that takes $content and appends some stuff to it.

I want this filter to be added after all other filters. I don't want it overwriting any other filter. The docs says default priority is 10, so I assume it is simply being added to a chain of filters that get run on the_content.

If I set the priority to 1, will it overwrite any core functions?

2 Answers 2


There is no definitive answer to that because there is no limit to priorities high/low. Also plugins can be much less careful than core with this.

  • 11 is good number to be after default priority;
  • 20 to be late;
  • multiple thousands is good to be later than anyone who didn't put more zeros in his thousands;
  • 9 is good number to be slightly earlier than default;
  • 1 to be really early;
  • -1 to be almost definitively first, because very few people remember that priorities can go negative.

Overall if you want to be sure you are before other functions you will have to dump everything that is added to hook in your specific setup and debug through that. You might need to create wrapper function to add your filters at specific load stage or even move other filters around.

And if you are making plugin for distribution you can guess, but you can't be sure.

  • A (very inefficient) way to make sure your filter runs last, is to hook into the all action, where you can examine the $wp_filter array and add your filter with the latest priority. So technically you can be sure, but it's not worth it. You could also use PHP_INT_MAX as your priority.
    – Jan Fabry
    Sep 23, 2010 at 8:04
  • Good point about all but I'd not use it that way. Terribly inefficient indeed. As for max I'd not go to extremes either... Priority is stored as array key, which can be interpreted both as integer and string by PHP. Going to corner cases might blow up.
    – Rarst
    Sep 23, 2010 at 8:20

You won't overwrite anything. Each priority level is actually a list of filters to use. If you have several different things hooking into the same filter at the same priority, they all get run.

  • you are wrong about this
    – user145078
    Sep 12, 2019 at 23:11
  • Just to add further clarification, this is partly correct and partly wrong. Indeed you don't overwrite core behavior; you either alter it before or after. Anyway all filters are by definition run sequentially so, sooner or later, all filters are executed exactly once and one at a time, core ones included, if any exist. From: Source which I quote: functions with the same priority are executed in the order in which they were added to the action .
    – GigiSan
    Oct 30, 2020 at 14:11

Your Answer

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