Hooked Editable Content iconCreate WP or text editors on Edit Post and Edit Page screens for content to be hooked into actions and filters.

(Also available on Github.)


An easy way to add content to actions or filters in your theme – and allow users to edit the hooked content by page and post if you wish.

Example uses:
  • Add a slider or image gallery to your site just below the main navigation menu and have the images varying on different pages. Or maybe have some pages without any images at all.
  • Add text in the site footer on some pages, but not on all pages. Or maybe different text on different pages.
  • Add an additional editor to all pages / posts that allows authors / editors to add in a banner notice to any given page / post if they wish.

How it works
  1. Work out where you want to add some content. If your theme already has a suitable action / filter, then great. (Themes like the free WooCommerce Storefront come with loads.) If not, you can add an action / filter yourself using a child theme.
  2. Create a “hooked editor” using the plugin, specifying the action / filter you want to hook the editor to, the type of editor, and which roles can add content.
  3. If you wish you can now add “generic” content to that hook, which will appear on every page and post.
  4. An editor also appears on every Edit page and Edit post screen for those users with the right role, so “specific” content can be added which will only appear on that page / post.
  5. Content saved against a post / page is now displayed on the front-end wherever the action / filter appears. If generic content has been saved, then any specific content replaces it on that page / post only.

If you have any questions, do please get in touch using the comments or the contact form.


Can I style the output from a specific hooked editor?

For hooked editors that are hooked to an action, yes. For those hooked to a filter, no.

The output from actions is wrapped in a div with classes hec-content and hec-content-[Hooked editor title] where [Hooked editor title] is converted to lower case and spaces have been replaced by hyphens.

So for example, if the hooked editor has the title ‘Site notice’, then you can target the output container using the css selector .hec-content-site-notice.

Can I disable the display of hooked content without losing the data?

Yes. Use the ‘Hide Hooked Content’ options for an editor. You can disable generic content, specific content, or both. The content will not be displayed on the front end.

How should I choose between using a WP Editor or a text editor?

It depends on the circumstances.

The WP Editor allows full html and shortcodes just like the normal post / page editor, while the text editor strips out any html, line breaks, etc. So text editor is probably best when you want to limit users to plain text content.

The full WP editor will generally be fine with an action, but filters might be a bit trickier. For example, if your theme outputs the filter like this echo esc_html( apply_filters( 'some_filter', $output ) ); then any html will be escaped. So unless you want to display escaped html, you’re better off preventing any user confusion by choosing the text editor.

How do I change the order in which hooked editors are displayed when editing pages / posts?

Click on ‘Hooked Editors’ in the main menu, then click on ‘Re-order hooked editors’ just below the main heading ‘Editors’ at the top of the screen. You can now drag the rows of the table into the order you want.

Can I change who can add and edit hooked editors?

Yes. By default, only administrators can add, edit and delete hooked editors. The plugin uses the following custom capabilities, all of which are added only to administrators:

edit_hec_hooks, edit_others_hec_hooks, publish_hec_hooks, read_private_hec_hooks, delete_hec_hooks, delete_private_hec_hooks, delete_published_hec_hooks, delete_others_hec_hooks, edit_private_hec_hooks, edit_published_hec_hooks

You can add some or all of these capabilities to other roles or users. Note that on deactivation the plugin only removes these custom capabilities automatically from the administrator role. If you add capabilities to other users or roles they will not be removed automatically.

Can I prevent / enable a hooked editor appearing on certain post types?

Yes, by selecting or de-selecting the post type in the ‘Included post types’ meta box when editing the hooked editor. You can also filter the included post types using the filter hec_included_post_types:

function mytheme_include_my_cpt( $included_post_types, $hooked_editor, $hooked_editor_info ) {
$included_post_types[] = 'my_custom_post_type';
return $included_post_types;
add_filter( 'hec_included_post_types', 'mytheme_include_my_cpt', 10, 3 );

What happens if I change theme?

If you switch to a new theme you won’t lose any of the hooked content, but it will be hooked to actions / filters in the old theme, so it won’t display to start with.

You will need to update the settings of your hooked editors so that they are hooked to actions / filters in your new theme. Note that you can hook an editor to more than one hook, so if you’re switching between themes a lot for some reason, you could hook an editor to one hook in one theme and an equivalent hook in another.