Ensuring a plugin is loaded/run last?

You’ll want to hook into “the_content” filter at a very high priority. Example:

function my_alter_the_content( $content ) {
    if ( in_array( get_post_type(), array( 'post', 'page' ) ) ) {
        // Do stuff here for posts and pages
    }
    return $content;
}
add_action( 'the_content', 'my_alter_the_content', PHP_INT_MAX 

);

Using the PHP_INT_MAX constant for the hook priority you can ensure it runs as last as possible (most plugins/themes will just use the default priority of 10).

The issue is when you say “after all ad injections…etc” that really depends how things are being added. Because if there are ads being added via javascript then of course the only way to override it would be via javascript.

Leave a Comment