Timeline for How to add script & PHP code to the <head> section of a block editor theme template?
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 27 at 11:06 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Jul 28 at 11:06 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Mar 28 at 9:05 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Aug 3, 2023 at 16:43 | answer | added | Tom J Nowell♦ | timeline score: 0 | |
Aug 3, 2023 at 14:37 | comment | added | Tom J Nowell♦ |
note that a map block would provide solutions for this. Likewise you don't need to use PHP to generate the center JSON, data attributes can do this already, and you can already use WP APIs to attach data to objects without having to manually print it out like that so this approach is already not ideal in a classic theme . Take a look at developer.wordpress.org/reference/functions/… and also consider using data attributes as right now this approach makes multiple maps impossible. Similarly in non-block themes you're meant to use filters to put stuff in the head
|
|
Aug 3, 2023 at 13:59 | comment | converted from answer | YourManDan |
There's probably a pure code solution that I'm not aware of, but I often use the free plugin WP Code for problems like this. In the "Header and Footer" section of the plugin, enter your code in the "Header" box and save. Should show up on every page in the <head> section. Just tested it with the Twenty Twenty-Three theme and it works with that.
|
|
S Aug 3, 2023 at 13:42 | review | First questions | |||
Aug 3, 2023 at 14:05 | |||||
S Aug 3, 2023 at 13:42 | history | asked | Ferienflieger | CC BY-SA 4.0 |