I'm running the following PHP Code Sniffs on some WordPress code, and the following warning pops up
352 | WARNING | get_posts is discouraged in favor of creating a new
| | WP_Query() so that Advanced Post Cache will cache
| | the query, unless you explicitly supply
| | suppress_filters => false.
While I'm an experienced programmer, I'm not super familiar with WordPress's history. This warning seems important, but is awkwardly worded. I'm confused on a few points, and other answers I've found on the subject don't seem to address my points.
What is the "Advanced Post Cache". I know WordPress (like a lot of PHP applications) has caching going on at a few different levels.
Is this warning telling me that
get_postswill never use the cache, butWP_Querywill?Is this warning telling me that using
suppress_filterswithWP_Querywill bypass the Advanced Post Cache? Or that usingsuppress_filterswithget_postswill invoke the cache? Or something else?What else does
suppress_filtersdo?
If someone more familiar with the matter could clue in a WordPress newb I'd appreciate it. I'm not looking for a "always use X, or never use Y" sort of answer -- I'm trying to understand the tradeoffs of each approach.
WP_Query, it's whatget_postsuses internally. Also as an aside, never usequery_postsunder any circumstances, and always remember to cleanup withwp_reset_postdata