Title: Adding php to a button
Last modified: January 31, 2024

---

# Adding php to a button

 *  [Dillx](https://wordpress.org/support/users/dillx/)
 * (@dillx)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/adding-php-to-a-button/)
 * 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](https://wordpress.org/support/users/jordesign/)
 * (@jordesign)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/adding-php-to-a-button/#post-17396522)
 * Hi [@dillx](https://wordpress.org/support/users/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](https://wordpress.org/plugins/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](https://wordpress.org/support/users/rawdolphe/)
 * (@rawdolphe)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/adding-php-to-a-button/#post-17396770)
 * And we have the **Code block** as well, which can be useful in some cases.
 *  Moderator [jordesign](https://wordpress.org/support/users/jordesign/)
 * (@jordesign)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/adding-php-to-a-button/#post-17397995)
 * Thanks for the suggestion [@rawdolphe](https://wordpress.org/support/users/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](https://wordpress.org/support/users/rawdolphe/)
 * (@rawdolphe)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/adding-php-to-a-button/#post-17403146)
 * Ow, thanks a lot [@jordesign](https://wordpress.org/support/users/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.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/twentytwentyfour/1.5/screenshot.
   png)
 * Twenty Twenty-Four
 * [Support Threads](https://wordpress.org/support/theme/twentytwentyfour/)
 * [Active Topics](https://wordpress.org/support/theme/twentytwentyfour/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/twentytwentyfour/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/twentytwentyfour/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 6 replies
 * 3 participants
 * Last reply from: [Gin](https://wordpress.org/support/users/rawdolphe/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/adding-php-to-a-button/#post-17403146)
 * Status: not resolved