wp_embed_register_handler to embed html files

Fixing the regex pattern

To match an url of the type:

https://coptic-treasures.com/
{Some string with a mix of a-z letters and hyphen}/{Some number}.html

like this example:

https://coptic-treasures.com/html-test-filed/02.html

you can try this kind of pattern:

'#https://coptic-treasures.com/([a-z-]+)/([0-9]+)\.html$#i'

and then you have to update the iframe output accordingly:

... src="https://coptic-treasures.com/%1$s/%2$s.html" ...

with the corresponding matches.

Demo

Here’s a test run:

text

that generates:

embed

Some notes

As far as I remember the embeds write some post meta data, so your approach does not avoid database actions.

But many WordPress installations have tens of thousand of non-hierarchical custom posts without major problems, so I would not rule that option out. Make sure you have a good hosting provider, that provides you with the latest PHP version etc. If the search becomes too slow, there are some third party solutions and services available out there.

Note that it could be a problem with the WordPress admin interface having so many hierarchical posts, because the parent dropdowns fetch all pages.

It’s also probably much easier to edit the data in the WordPress backend (utilizing things like revisions and taxonomies), instead of finding the corresponding bare file each time, open it and modify it that way. Unless it’s exported from another system you have in place.

Another approach might to use e.g. Vue/React/… JS and fetch the pure data as json(p) resources and format it as needed, but I’m not sure about the search engine visibility in that case.