PMG Digital Made for Humans

The Most Interesting File in WordPress

2 MINUTE READ | May 25, 2012

The Most Interesting File in WordPress

Author's headshot

Christopher Davis

Christopher Davis has written this article. More details coming soon.

The thing that makes WordPress an amazing flexible CMS (and, increasingly, a basic application framework) is its system of hooks.

Hooks are places where a developer can fire a function that either performs specific actions or filters/changes the output that gets sent to the user.

The WordPress core effectively eats it’s own dog food. Rather than specifically formatting the output of the_content() inside the function, for instance, the WordPress core adds filters to the_content. This means, of course, that you, as a user/developer are free to unhook those formatting functions and do whatever you want.

To see all the actions and filters the WordPress core uses, you needn’t look any further than wp-includes/default-filters.php.

As an example, let’s explore what exactly happens when one uses the the_content(); function. Here’s that function:


function the_content($more_link_text = null, $stripteaser = false) {  $content = get_the_content($more_link_text, $stripteaser);  $content = apply_filters('the_content', $content);  $content = str_replace(']]>', ']]>', $content);  echo $content;


Most of the WordPress core follows this sort of design pattern: the_something is a wrapper around get_the_something that only echoes out the value (and usually runs it through a filter).

In this case, the line we’re interested in is the apply_filters('the_content', $content);. This tells WordPress to fire the filter hook the_content. Any functions hooked into the_content will fire, receiving the post content as an argument. Now that we know which filter fires, we can go explore the default filters file to see what happens:


add_filter( 'the_content', 'wptexturize'        );

add_filter( 'the_content', 'convert_smilies'    );

add_filter( 'the_content', 'convert_chars'      );

add_filter( 'the_content', 'wpautop'            );

add_filter( 'the_content', 'shortcode_unautop'  );

add_filter( 'the_content', 'prepend_attachment' );

There are six separate functions hooked into the_content here – there are actually a few more hooked into the_content in other parts of the default filters file. Now that you know what functions are getting fired, you can go and figure out what exactly they do. wptexturize, for instance, converts certain characters into their html entity equivalents.

Stay in touch

Bringing news to you

Subscribe to our newsletter

By clicking and subscribing, you agree to our Terms of Service and Privacy Policy

Most of the time, how the core uses its own hook system doesn’t matter. But when you want to change WordPress’ default behavior, you are able to. It’s also possible that the filters the core uses may conflict or cause unexpected behavior in your theme or plugin. At that point, it’s up to you to track things down.

Related Content

thumbnail image

AlliPMG CultureCampaigns & Client WorkCompany NewsDigital MarketingData & Technology

PMG Innovation Challenge Inspires New Alli Technology Solutions

4 MINUTES READ | November 2, 2021

thumbnail image

Applying Function Options to Domain Entities in Go

11 MINUTES READ | October 21, 2019

thumbnail image

My Experience Teaching Through Jupyter Notebooks

4 MINUTES READ | September 21, 2019

thumbnail image

Working with an Automation Mindset

5 MINUTES READ | August 22, 2019

thumbnail image

3 Tips for Showing Value in the Tech You Build

5 MINUTES READ | April 24, 2019

thumbnail image

Testing React

13 MINUTES READ | March 12, 2019

thumbnail image

A Beginner’s Experience with Terraform

4 MINUTES READ | December 20, 2018