我试图通过post类型、元键和元值来准备WPDB
global $post;
global $wpdb;
$rid = absint($_POST["rid"]); // number
$last_id = absint($_POST["lastID"]); // post ID
$query = $wpdb->prepare(
"
SELECT ID
FROM $wpdb->posts
WHERE ID > %d
AND wp_posts.post_type = \'room\'
AND wp_postmeta.meta_key = \'rid\'
AND wp_postmeta.meta_value = %s
ORDER BY wp_posts.ID DESC
LIMIT 0, 1", $last_id, $rid);
$results = $wpdb->get_results( $query );
foreach ( $results as $row ) {
echo $row->ID;
}
die();
我只想得到符合条件的最后一个ID