Skip to main content
Documentation/Elements Reference/Other/PHP Code
Elements Reference

PHP Code

The PHP Code element runs PHP on the server when the page renders and outputs whatever
the code prints. Use it for small dynamic snippets — calling a WordPress function,
printing a computed value — without writing a plugin.

Content

The PHP Code element's Content tab, with its syntax-highlighted code editor
  • PHP Code — the code editor, with syntax highlighting. Start with <?php; you can
    mix PHP and HTML the way you would in a template file, and use any WordPress function.
  • Disable Builder Label / Builder Label — the builder shows a striped label
    block above the code's rendered output; rename or hide it with these controls. The
    label never renders on the real page.

The code also runs when the builder renders the element, so the canvas shows its real
output.

If the code has a syntax error, the element renders "An error occurred inside the PHP
Code Block element" with the error message and line number instead of breaking the
page.

This is real server-side PHP — it runs with the same access as your theme and
plugins on every render of the page. Treat it like editing a theme file: a runtime
mistake (a syntax error is caught, but a fatal call is not) can take the page down.

On the front end

The element renders a wrapper div with a generated per-element class and the
oxy-php-code class, containing whatever your code printed.

  • HTML Code — static markup, no server-side
    execution.
  • Shortcode — run existing plugin functionality
    without writing code.