
Many users have asked whether it’s possible to count views for manga chapters in WordPress, especially for those using the Madara theme. While we plan to develop a plugin for this feature, it takes time. So, I’ve created this simple guide to help you implement chapter view counting in just a few minutes!
Even if you don’t have coding experience, you can simply copy and paste the provided code into your child theme’s functions.php
file.
1. Quick Setup for Counting Views in Manga Chapters
If you want a quick solution, here’s what you need to do:
1️⃣ Copy the full source code from this link.
2️⃣ Paste the code into your child theme’s functions.php
file.
3️⃣ Switch to the parent theme, then switch back to the child theme to activate the code.
This method will add a view counter for each manga chapter in your Madara-based site.
2. Full Code to Count Views for Manga Chapters
A. Adding a “Views” Column to the Manga Chapters Table
First, we need to add a new column to store chapter views in the database. This function runs when switching themes:
B. Displaying Views on Manga Chapters
Next, we display the view count on each manga chapter page:
C. Increasing View Count (Madara Core 1.5 and Below)
For Madara Core versions prior to 1.6, use the following function to increase views when a chapter is loaded:
D. Counting Views for Madara Core 1.6+ (Supports Page Cache)
For Madara Core 1.6+, replace the function above with this one to ensure compatibility with page caching:
3. How This Works
Here’s a breakdown of the process:
✔ Step 1: Add a views
column to the manga_chapters table.
✔ Step 2: Use after_manga_single
to increase the view count each time a chapter is loaded.
✔ Step 3: Display the number of views using wp_manga_after_chapter_name
.
This method ensures that each manga chapter gets a proper view counter, making it easier to track reader engagement.
4. Conclusion: Start Counting Views for Manga Chapters Today!
With this simple method, you can easily count views for manga chapters in WordPress using the Madara theme. Whether you’re using Madara Core 1.5 or 1.6+, you now have the right solution!
💡 Try it out and let us know if it works for you! 🚀
lung shaw
I use full source code 1.6+ but it doesn’t work, even though I have successfully updated the file
kübra çınar
i can’t run the code
coldheate05
did not work