I am placing a small code snippet in a WordPress.com web page. WordPress.com provides a "Code Block" option for formatting code.

Is there a way to add line numbers to the code in this code block?

  • Line numbers are most useful when you need to refer to specific lines from the code. For example, compilers will often say what line number cause a compiler error. On websites, it is fairly rare to put line numbers on code blocks. Stack Overflow has tons of code and doesn't number the lines. Do you have a case in which you want to refer to the line numbers of the code in your blocks? Sep 13, 2021 at 15:36
  • 1
    I want to explain code line by line in tutorials. So, I need to refer w.r.t. the line number during explanation. @StephenOstermiller
    – hanugm
    Sep 13, 2021 at 16:16
  • 1
    Please comment the reason for downvote if possbile as I am new to this site.
    – hanugm
    Sep 14, 2021 at 10:17

2 Answers 2


From what I can tell, it looks like WordPress.com's SyntaxHighlighter Code Block shows line numbers, whereas their Code Block does not. My understanding is that the SyntaxHighlighter Code Block is a fancier, more full-featured code block type that's built into WordPress.com.

See the SyntaxHighlighter Code Block documentation for more info:


Have you looked at WP plugins to replace the default editor? I personally have avoided the default editor for a couple of years.

A quick search of code editors for Wordpress will give you many different editors. Several of them have line number functionality. However, you will want to make sure they all work with the current "block" technology of the new Gutenberg Editor (about 2 years old).

Here's one with a screenshot of it's line numbers.

Whether they will specifically work inside of code blocks as opposed to inline as shown in the example would require testing. The one shown in the screenshot specifically says it doesn't work with "blocks in the visual editor".

Your Answer

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

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