PHP Code Widget icon
Content & Editing

PHP Code Widget

Like the Text widget, but also allows working PHP code to be inserted.

  • By Samuel Wood (Otto)
  • v2.4
  • Updated
Not updated in over two years. It may not work with current WordPress versions. Test it on a staging site first.

Overview

PHP Code Widget describes itself as: “Like the Text widget, but also allows working PHP code to be inserted.”

It is active on 70,000+ WordPress sites and rated 4.7 out of 5 by 61 users on WordPress.org. Developers can extend it through 0 actions and 2 filters, listed below.

We haven't published a hands-on review of PHP Code Widget yet. Want one, or need help with it? Send us a request.

How to install PHP Code Widget

  1. Open the plugin installer. In your WordPress dashboard go to Plugins → Add New Plugin.
  2. Search for it. Type “PHP Code Widget” and pick the one by Samuel Wood (Otto).
  3. Install and activate. Click Install Now, then Activate.
Install with a zip file or WP-CLI

Download the zip from the WordPress.org plugin page, then go to Plugins → Add New Plugin → Upload Plugin, choose the file and click Install Now. Or from the command line:

wp plugin install php-code-widget --activate

Requirements: WordPress 2.8+ · tested up to WordPress 5.9.20

Hooks & customisation

PHP Code Widget 2.4 fires 0 actions and 2 filters. Use them from your child theme or a snippets plugin to change how it behaves without editing its files.

php-code-widget — top hooks
// Filter in execphp.php
apply_filters( 'widget_execphp', $instance['text'], $instance );

// Filter in execphp.php
apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );

Browse all 2 hooks with examples →

Need PHP Code Widget customised?

Tell us what you want changed, added or fixed and we'll reply with an estimate.

WP EXPERTS is independent and not affiliated with Samuel Wood (Otto). Plugin names and logos belong to their owners. Version, rating and install figures from WordPress.org, checked Nov 17, 2026.

Alternatives in Content & Editing

See all →

Enables the previous "classic" editor and the old-style Edit Post screen with TinyMCE, Meta Boxes, etc. Supports all plugins that…

8+ million installs Reviewed 4 hooks

Duplicate Posts, Pages and Custom Posts easily using single click

3+ million installs Reviewed 3 hooks

The go-to tool for cloning posts and pages, including the powerful Rewrite & Republish feature.

3+ million installs Reviewed 21 hooks

Enables the previous "classic" widgets settings screens in Appearance - Widgets and the Customizer. Disables the block editor from managing…

2+ million installs Reviewed