Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Method by which plugins and themes extend core WordPress functionality.

There are two types of hooks that your plugins and themes can use:

  1. Actions: These hooks allow for execution of your functions during specific events such as when a post is saved, or an attachment is deleted -
    Plugin API/Action Reference « WordPress Codex
  2. Filters : These hooks alter text during specific events, such as prior to the content being displayed, or prior to post data being updated -
    Plugin API/Filter Reference « WordPress Codex

An example of adding a filter to enable an extra TinyMCE button:

// add horizontal rule button
function enable_more_buttons($buttons) {
    $buttons[] = 'hr';
    return $buttons;
add_filter('mce_buttons', 'enable_more_buttons');

The filter being hooked onto is mce_buttons, the callback function is enable_more_buttons, defined above. This function will now run whenever the mce_buttons hook (used to build the primary toolbar in the WYSIWYG editor) is triggered.

Related Links