$wpdb-get_results举例
$wpdb->get_results is a method in WordPress that is used to retrieve multiple rows from a database table. It returns an array of objects or arrays representing the rows fetched from the database.
Here is an example of using $wpdb->get_results:
global $wpdb;
// Retrieve all rows from the 'wp_posts' table
$results = $wpdb->get_results( "SELECT * FROM wp_posts" );
// Loop through the results and display the post titles
foreach ( $results as $post ) {
echo $post->post_title . "<br>";
}
In this example, we are using $wpdb->get_results to fetch all rows from the 'wp_posts' table in the WordPress database. We then loop through the results and display the post titles for each row fetched
原文地址: https://www.cveoy.top/t/topic/hZ0c 著作权归作者所有。请勿转载和采集!