I want to get the latest 9 items of nodes in a preprocessor, so that I can display these items in an latest news strip.
I have the following function:
function mytheme_preprocess_page__front(&$variables) { $entities = Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'news']); $news = []; }
The above however returns all news items. I have searched high and low but cannot find on how to expand the loadByProperties method to achieve this?