In this tutorial, you will learn how to convert a paragraph block into a number counter without plugins.

Wordpress customization


free WordPress tut update


Wordpress code snippet


fast WordPress


Add number counter in WordPress without plugins!

Add The Following Code to the functions.php File

In the WordPress dashboard, go to Appearance ➡ Theme File Editor and copy the following code into the child theme’s functions.php file and update it.

You must create a child theme before making any changes to functions.php file. Otherwise, the applied changes will be lost after each update.
Create child theme in WordPress step by step [without plugin]

As an alternative method, you can use the Code Snippets plugin to insert your codes into WordPress.

* Number Counter in WordPress by WPCookie
add_filter( 'wp_footer', function ( ) {  ?>
const counters = document.querySelectorAll('.counter');
if (counters) {
	const observer = new IntersectionObserver(entries => {
    entries.forEach( entry => {
      if ( entry.isIntersecting ) { 
      const finalNumber =;
      const time = Math.ceil(finalNumber / 30) ; = 0;
      const animate = () => {
	      const data =;			   
        if(data < finalNumber) { 
   = Math.ceil(data + time);
            setTimeout(animate, 50);
   = finalNumber;
  }, {threshold: 0.1 })

  counters.forEach( counter => {
<?php });

Convert a paragraph block to a number counter

Add a paragraph block, write a number inside it, and assign it the “counterclass. That’s it, you can also change the style of the paragraph to your liking.

For example, the above pattern is made by the following blocks. A row block in which there are four groups and in each group there is an image block and a paragraph with the “counter” class.

Number counters pattern in Gutenberg WordPress

If this article is difficult for you to read in text, you can watch the video version below.

Share this post

Hi, my name is Maya and I’m a WordPress plugin developer. I created this website to share some of the helpful codes that I’ve used in my own projects.
If you’re looking for a custom plugin for your website, you can contact me by clicking on Hire a developer in the menu. I’d love to hear from you.

Articles: 53

Leave a Reply

Your email address will not be published. Required fields are marked *