Apply the_content filter for specific post types only

Whenever the_content is called, there is a global WP_Post object. So you can look into that to find its post type:

if ( ! in_array( get_post()->post_type, [ 'tool', 'article' ] ) )
    return $content;

Leave a Comment