Documentation Uncached Functions

Uncached Functions

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 of get_posts() are not cached via Advanced Post Cache.
    • Use WP_Query instead, or set 'suppress_filters' => false
  • wp_get_recent_posts()
    • See get_posts()
  • get_children()
    • Similar to get_posts(), but also performs a no-LIMIT query among other bad things by default. Alias of break_my_site_now_please(). Do not use.
  • wp_get_post_terms(), wp_get_post_categories(), wp_get_post_tags(), and wp_get_object_terms()
    • Use get_the_terms() along with wp_list_pluck to extract the IDs
  • get_category_by_slug()
  • get_term_by()
  • term_exists()
    • Use wpcom_vip_term_exists() instead
  • get_term_link(), get_tag_link(), and get_category_link()
    • Use wpcom_vip_get_term_link() instead
  • get_cat_ID()
  • get_page_by_title()
  • get_page_by_path()
    • Use wpcom_vip_get_page_by_path() instead
  • url_to_post_id()
    • Use wpcom_vip_url_to_postid() instead
  • count_user_posts()
    • Use wpcom_vip_count_user_posts() instead
  • wp_get_post_(categories|tags|terms)
  • wp_old_slug_redirect()
    • Use wpcom_vip_old_slug_redirect() instead.