我正在尝试对分页进行计数,并将其返回NULL,这就是为什么查询会正确返回结果。在这种情况下,$total返回NULL,这是不正确的,为什么?(我没有包括$args,因为它们有效)
$total_query = "SELECT COUNT(*) FROM (${args}) AS total_count";
$total = $wpdb->get_var( $total_query );
$items_per_page = 5;
$page = isset( $_GET[\'cpage\'] ) ? abs( (int) $_GET[\'cpage\'] ) : 1;
$offset = ( $page * $items_per_page ) - $items_per_page;
$results = $wpdb->get_results( $args . " ORDER BY user_registered DESC LIMIT ${offset}, ${items_per_page}" );