the content – When should I use add_action(‘the_post’ vs add_action( ‘the_content’ vs apply_filters( ‘the_content’?
Reading through the WordPress codex, it isn’t superbly clear to me when I should use add_action('the_post'
vs add_action( 'the_content'
vs apply_filters( 'the_content'
.
Are there specific scenarios when they should be used or avoided?
For example, if I use add_action('the_post'
with preg_match_all( '/<img\s+src\s*=\s*[\""\']?([^\""\'>]*)/i', $post->post_content, $matches );
, it returns the URI along with the rest of the content in the post.
However if I use add_action( 'the_content'
, it appears to modify the post and replace all the content with the URI.
Leave an answer