Answer the question
In order to leave comments, you need to log in
How to transfer the value received from the database to a variable?
Sending a query to the database
$items = $wpdb->get_results( "SELECT count(*) FROM `avt_posts` WHERE `post_type` = 'shop_order'" );
var_dump($items);
array(1) { [0]=> object(stdClass)#21691 (1) { ["count(*)"]=> string(3) "145" } }
Answer the question
In order to leave comments, you need to log in
$items = $wpdb->get_results( "SELECT count(*) AS `count` FROM `avt_posts` WHERE `post_type` = 'shop_order'" ); // изменённый запрос
$item = reset($items);
$x = $item->count;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question