Yes, the WordPress function
get_post( post_id ) queries the database to retrieve the post data.
get_post() function retrieves a post object based on the provided post ID. It first check if the post is already present in the cache, if not it retrieves it from the database using the
wp_cache_get() function with the post ID as key. If the post is not present in the cache, the function retrieves it from the database using the
WP_Query class and stores it in the cache using the
wp_cache_set() function for future use.
It’s important to note that the function returns a
WP_Post object, which is a PHP object representation of a post in the WordPress database. This means that it does not return the raw data from the database, but rather a structured and formatted version of the data that is easier to work with in a WordPress context.
Last modified: March 3, 2023