Skip to content


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. Listed below are some of these uncached functions and their VIP cached alternatives.


Use wpcom_vip_attachment_url_to_postid() instead.


Use wpcom_vip_count_user_posts() instead.

get_adjacent_post(), get_previous_post(), get_next_post(), previous_post_link(), next_post_link()

Use wpcom_vip_get_adjacent_post() instead.


This function is similar to get_posts() and in fact, calls get_posts(). The problem with this query is that by default, it will run a no-LIMIT query and set suppress_filters to true. That can cause problems because it will skip our query caching (brought to you by Advanced Post Cache), and cause unintended performance consequences when a post has too many children. We’ve seen instances where a simple get_children() call for an attachment can cause 503’s on a site due to the amount of database calls and cache updates it can generate. We recommend that you use WP_Query instead and follow these guidelines:

  • Do not set the post_parent to 0 or a false value. Those settings would request every post on the site.
  • Set the posts_per_page to your absolute minimum requirement, and no higher than 100. The lower the value you set for posts_per_page, the better performance you can expect.


Use wpcom_vip_get_page_by_path() instead.


Use wpcom_vip_get_page_by_title() instead.


Unlike WP_Query, the results of get_posts() are not cached via Advanced Post Cache.

Use WP_Query instead, or set 'suppress_filters' => false.

$args = array(
    'post_type'        => 'post',
    'posts_per_page'   => 3,
    'suppress_filters' => false,
$query = get_posts( $args );

When using WP_Query instead of get_posts don’t forget about setting ignore_sticky_posts and no_found_rows params appropriately (both are hardcoded inside a get_posts function with value of true ).


Use wpcom_vip_term_exists() instead.


Use wpcom_vip_url_to_postid() instead.


get_the_terms is a better option, but both can return a WP_Error object and thus needs a bit of checking before accessing the results.


See get_posts() .


Use wpcom_vip_wp_oembed_get() instead.


Use wpcom_vip_old_slug_redirect() instead.

Last updated: January 31, 2022