node_get_recent()
is unused in core and is now deprecated, developers can use views or EntityQuery to get the nodes which are recently modified or added.
Earlier drupal developers used to use the function node_get_recent()
to get the recently changed nodes like seen in below example
$latest_updated_nodes = node_get_recent(10);
Now from Drupal 10.1.x onwards, developers need to use entity query to fetch the recently changed nodes like seen in below example
$nids = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', NodeInterface::PUBLISHED)
->sort('changed', 'DESC')
->range(0, 10)
->addTag('node_access')
->execute();
$latest_updated_nodes = !empty($nids) ? Node::loadMultiple($nids) : [];
Or Drupal Developers can use Views, where you create a View and add sort criteria with the latest updated date and fetch expected number of records.
Thanks for reading the article, for more drupal related articles read and subscribe to peoples blog articles.