Easy Way To Add PHP To A Page

Is there an easy way to add PHP to a page? I would love to be able to use a content block, but that seems to only allow html and css.

Hello @nhorstmann,

Thanks for asking. :slight_smile:

Well, you can use Conditional tags along with page id to write PHP code that will execute only on that page. For ex:

<?php if ( is_page('432') ) : ?>

/* Add you PHP code here */
<?php endif; ?>

I am sharing relevant tutorial links that you can take a look to get started.

https://codex.wordpress.org/Conditional_Tags

https://developer.wordpress.org/themes/basics/conditional-tags/

https://developer.wordpress.org/themes/references/list-of-conditional-tags/

Hope that helps you to get started.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.