• Im try to insert a call to a php function in a button before the link. Im using the block editor and ‘editing as html’ function. it won’t save the button as it doesnt recognise the html. Im actually trying to do something quite simple – store calling page/post in a global variable.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator jordesign

    (@jordesign)

    Hi @dillx – it’s not currently possible to include PHP code directly within the template within the Block Editor. What I’d suggest is writing a small plugin, or using a plugin like Code Snippets to include your PHP in a way where it is injected into the page on page load, rather than needing to be part of the template itself.

    Gin

    (@rawdolphe)

    And we have the Code block as well, which can be useful in some cases.

    Moderator jordesign

    (@jordesign)

    Thanks for the suggestion @rawdolphe – unfortunately the Code Block won’t allow/process PHP code. So it definitely is handy for some cases – like including code snippets to read – but won’t change the functionality of the page.

    Gin

    (@rawdolphe)

    Ow, thanks a lot @jordesign, I didn’t know that it was just for display!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding php to a button’ is closed to new replies.