WordPress core has a number of functions that, for various reasons, are uncached, which means that calling them will always result in an SQL query. Below, we outline some of these functions. We have a helper file with cached versions of some of the functions, which is automatically available to you.
get_posts()- Unlike
WP_Query, the results ofget_posts()are not cached via Advanced Post Cache. - Use
WP_Queryinstead, or set'suppress_filters' => false
- Unlike
wp_get_post_terms()andwp_get_object_terms()- Use
get_the_terms()along withwp_list_pluckto extract the IDs
- Use
get_category_by_slug()- Use
wpcom_vip_get_category_by_slug()instead
- Use
get_term_by()- Use
wpcom_vip_get_term_by()instead
- Use
get_cat_ID()- Use
wpcom_vip_get_term_by()instead
- Use
get_page_by_title()- Use
wpcom_vip_get_page_by_title()instead
- Use
get_page_by_path()- Use
wpcom_vip_get_page_by_path()instead
- Use