79368825

Date: 2025-01-19 11:16:35
Score: 0.5
Natty:
Report link

There are many ways to achieve this, but none are trivial.

The Gutenberg Cheat code

Make a server-side rendered block, and use $wp_query->current_post +1; to get the index of the post inside the loop.

With CSS

Using counter(), see : How do I achieve automatic numbering for headings using css

Using filter

The worst way because you can't see the result in Gutenberg editor, but you can filter the core/post-template block with the render_block filter and replace the ul html tag with ol

The better solution ?

The better solution is programming a custom block doing the same as the core/post-template with your addition. You can find the source here: https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-template

Reasons:
  • Blacklisted phrase (1): How do I
  • Whitelisted phrase (-1): solution is
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Seb