load_meta()
public function load_meta( int $id )
This method loads all post meta for the provided post ID into the $loaded_meta class property. This is useful when looping through posts for a layout component displayed on a single post, and does not require existing post meta values to be requiried. As with meta for the current post (if building a layout for a single post), methods are provided to assist in using loaded post meta. These methods include: get_loaded_meta(), get_serialized_loaded_meta(), get_loaded_headline(), and get_loaded_content()
#
Arguments- $id
(int) (required) The post ID to retrieve post meta for.
#
ReturnThis method does not return any value.
#
ExampleIn the following example, we'll create a layout component for the build_components() method that displays a grid of employees and some basic information about them...
In the example above, we use WordPress' get_posts() function to pull an array of post IDs for the method_team post type. Then, if any post IDs are returned, we set up the opening HTML for a grid. Then, we loop through each post ID, using the load_meta() method to load the post meta for each item. We then use the some of Method's utility methods to interact with the retrieved post meta for each item.