I use mod_articles_category to display a list of categories with their articles.

I need to display the total of articles next to each category title. I've tried with <?php echo $item->numitems; ?> - found in com_content/categories - but it doesn't help.

defined('_JEXEC') or die;

use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Content\Site\Helper\RouteHelper;

if (!$list) {


<ul class="row">
    <?php if ($grouped) : ?>
        <?php foreach ($list as $groupName => $items) : ?>
        <div class="col">
            <div class="mod-articles-category-group fs-3 fw-bold"><?php echo Text::_($groupName); ?>                 
                <span class="ps-3 text-muted fw-light fs-5"><?php echo $item->numitems; ?> articles</span>                   
            <ul class="list-unstyled">
                <?php foreach ($items as $item) : ?>
                <li class="py-2">
                    <?php if ($params->get('link_titles') == 1) : ?>
                        <?php $attributes = ['class' => 'mod-articles-category-title ' . $item->active]; ?>
                        <?php $link = htmlspecialchars($item->link, ENT_COMPAT, 'UTF-8', false); ?>
                        <?php $title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false); ?>
                        <img src="images/svg/caret.svg" alt="" width="13" height="13" class="pe-2"><?php echo HTMLHelper::_('link', $link, $title, $attributes); ?>
                    <?php else : ?>
                        <?php echo $item->title; ?>
                    <?php endif; ?>

                <?php endforeach; ?>

            <p class="ms-3 pt-3"><i class="far fa-arrow-alt-circle-right pe-2"></i>See all articles about 
                <span class="mod-articles-category-category">
                    <?php echo $item->displayCategoryTitle; ?>
        <?php endforeach; ?>
    <?php else : ?>
        <?php $items = $list; ?>
        <?php require ModuleHelper::getLayoutPath('mod_articles_category', $params->get('layout', 'default') . '_items'); ?>
    <?php endif; ?>

2 Answers 2


I suppose you want it with an override but if not really needed you can do easily with Article Anywhere plug-in and [count] info ;-)

  • Yes I want to acheive this with an override, not with an extension.
    – Mint
    Feb 27 at 5:32

I've added count($items); in the loop to get the number of items:

        <div class="ms-3 mod-articles-category-group fs-3 fw-bold"><?php echo Text::_($groupName); ?>                
            <span class="ps-3 text-muted fw-light fs-5"><?php echo count($items); ?> articles</span>                 
  • Please include an educational explanation with this snippet. Feb 27 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.