WordPress's Twenty Twenty-Four theme makes it possible to add custom fields directly in the editor
This UI is not coming from TwentyTwentyFour, and was added to WP decades ago:
https://wordpress.org/documentation/article/assign-custom-fields/
It predates 2024/2023 and was even present when the original Kubrick theme was the default theme, this is because it's a part of WordPress itself.
Instead we can generalise your question to:
Q: How Do I Display The Values of custom Fields in a Block Theme?
Since you can't put a snippet of PHP in a template like a classic theme that says echo get_post_meta(....etc
you're forced to write code using one of these options:
- via a shortcode
- in a server rendered/dynamic block (best)
- via a plugin
At the time of writing they're discussig the replacement of this particular UI and how using custom fields in block themes might work in the future.
The best detailing of this is the 12 minute section of the 2023 State of the word video where the technical lead demos it:
https://www.youtube.com/watch?v=c7M4mBVgP3Y
See 23 minutes in.
Also:
I created a 'single.php' file along with get_post_meta(), the custom fields show up, but none of the formatting (header, footer etc) disappeared.
This is because 2024 is a block theme, not a classic PHP theme. Using single.php
completely bypasses the block based templating system.
This is the old way of doing things.
If I edit the template, then only the meta block is available, but no way of accessing the custom fields.
As I mentioned earlier, this is because this functionality hasn't been implemented in the UI and requires a developer to write code for a block. Shortcodes via the shortcode block may also be an option.