What are the recommended methods for optimizing database calls in WordPress customization?

Optimizing database calls in WordPress customization involves minimizing the number of queries, using efficient query methods, and caching query results when possible. One way to achieve this is by utilizing the $wpdb global object provided by WordPress, which allows for direct database queries with built-in sanitation and escaping functions.

global $wpdb;

// Example of optimized database query using $wpdb
$results = $wpdb->get_results( "SELECT * FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish'" );