the content – When should I use add_action(‘the_post’ vs add_action( ‘the_content’ vs apply_filters( ‘the_content’?

Question

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.

0
Ryan 1 month 2022-08-18T04:31:48-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse