What is the best / efficient way to get WordPress content by post id and why?

The methods you offer for comparison are pretty much the same, with minor API differences and whether the_content filters are applied.

Within the loop get_the_content() should typically be used, which properly handles split into pages and so on.

To retrieve raw content get_post_field() is generally suitable, but any further processing (such as the_content filters) heavily depends on specific purpose of retrieving content and what you are going to do with it.

PS take note that many extensions out there are dumb and variously break on the_content filter executed outside of loop / more than once.

Leave a Comment