WordPress does not execute PHP pasted into a post. This guide explains how to run PHP with WPCode and display its output through a shortcode, using the site’s configured time zone as an example.
Before you begin
Back up the site and test on staging. Only use PHP you understand and trust: it runs on the server with WordPress’s permissions.
Create the snippet
-
Open Plugins > Add New Plugin, search for WPCode, check compatibility, then install and activate it.
-
Open Code Snippets > Add Snippet and choose the custom-code option.
-
Name it Show site time zone and choose PHP Snippet.
-
Enter this code without an opening
<?phptag:echo esc_html( wp_timezone_string() ); -
Under Insertion, choose Shortcode.
-
Activate the snippet and select Save Snippet or Update.
Display the output
Copy the generated shortcode into a Shortcode block in the required post or page.
Save and check that its output matches Settings > General.
For automatic execution, choose Auto Insert instead and configure its location and conditions. Automatic and shortcode insertion are alternative modes; choose the mode needed for the snippet.




