When you use custom news sorting or filtering using the newsListFetchItems hook, you might also need to use the newsListCountItems hook, so that the pagination works correctly. With this hook you return the number of news items, that would be shown in the current request.


  1. array $newsArchives

    The IDs of the news archives shown in this news list.

  2. bool $featuredOnly

    Whether or not to show only featured news.

  3. \Contao\Module $module

    The front end module instance executing this hook.

Return Values

Return false if this hook should not be considered. Return an integer otherwise.


// src/EventListener/NewsListCountItemsListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\Module;

class NewsListCountItemsListener
    public function __invoke(array $newsArchives, bool $featuredOnly, Module $module)
        if () {
            // Query the database and return the number of records
            return $numberOfRecords;

        return false;