Thanks for this code snippet. It helped me to solve my problem also.
Although I am facing another issue, maybe you can guide me in the right direction.
How can we count the articles of a specific category?
Let’s say I have four categories and I want to find how many articles are there in each category.
I’ll be very thankful to you for your help.