node_get_recent() is deprecated in Drupal 10.1.x

node_get_recent() is deprecated in Drupal 10.1.x

On9th May 2023, 2025-02-19T11:25:38+05:30 ByKarthik Kumar D K | read
Listen Pause Resume Stop

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.

Related Articles

Recent Articles

Recent Quick Read

Recent Great People

Shop Smarter with Our Reviews!

Shop Smarter with Our Reviews!

We sift through the noise to bring you only the best products. Read our in-depth reviews and make your shopping experience seamless!

Read the Reviews

Discounts Just for You!

Don't miss out on our exclusive offers! Browse our collection of discounted products and find great deals before they are gone

Grab your Discount
X
We Need Your Consent
By clicking “Accept Cookies”, you agree to the storing of cookies on your device to enhance your site navigation experience.
I Accept Cookies